DataSetBuilder.st
changeset 983 286a039ea7d1
parent 949 2e3469100a6a
child 1004 b7bfaa2d6ecd
equal deleted inserted replaced
982:2dda94c7ff25 983:286a039ea7d1
    89         height
    89         height
    90         menu
    90         menu
    91         foregroundSelector
    91         foregroundSelector
    92         backgroundSelector
    92         backgroundSelector
    93         doubleClickedSelector
    93         doubleClickedSelector
       
    94         rowSeparatorSelector
    94         selectSelector
    95         selectSelector
    95         printSelector
    96         printSelector
    96         readSelector
    97         readSelector
    97         writeSelector
    98         writeSelector
    98         rendererType
    99         rendererType
    99         showColSeparator
   100         showColSeparator
       
   101         showSelectionHighLighted
   100         showRowSeparator
   102         showRowSeparator
   101         backgroundColor
   103         backgroundColor
   102         foregroundColor
   104         foregroundColor
   103         labelForegroundColor
   105         labelForegroundColor
   104         labelBackgroundColor
   106         labelBackgroundColor
   125      UIHelpTool openOnClass:DataSetBuilder    
   127      UIHelpTool openOnClass:DataSetBuilder    
   126     "
   128     "
   127 
   129 
   128     <resource: #help>
   130     <resource: #help>
   129 
   131 
   130     ^super helpSpec addPairsFrom:#(
   132     ^ super helpSpec addPairsFrom:#(
   131 
   133 
   132 #addColumn
   134 #addColumn
   133 'Adds a new column.'
   135 'Adds a new column.'
   134 
   136 
   135 #basicsEditor
   137 #basicsEditor
   205 'Turns on/off displaying column separators.'
   207 'Turns on/off displaying column separators.'
   206 
   208 
   207 #frameShowRowSeparator
   209 #frameShowRowSeparator
   208 'Turns on/off displaying row separators.'
   210 'Turns on/off displaying row separators.'
   209 
   211 
       
   212 #frameShowRowSeparatorSelector
       
   213 'An optional selector, which is used to test whether the row separator at the bottom is shown.'
       
   214 
   210 #generate
   215 #generate
   211 'Code generation.'
   216 'Code generation.'
   212 
   217 
   213 #generateCode
   218 #generateCode
   214 'Generate code and install in the selected class/selector.'
   219 'Generate code and install in the selected class/selector.'
   231 #selectionLabelClickSelector
   236 #selectionLabelClickSelector
   232 'A selector called if label cell was clicked.'
   237 'A selector called if label cell was clicked.'
   233 
   238 
   234 #selectionLabelSelectorArgument
   239 #selectionLabelSelectorArgument
   235 'An argument passed to label selection selector.'
   240 'An argument passed to label selection selector.'
       
   241 
       
   242 #showSelectionHighLighted
       
   243 'Show selected cell highligthened (change fg/bg color).'
   236 
   244 
   237 #valuesChoiceSelector
   245 #valuesChoiceSelector
   238 'A selector returning a collection of choices for a cell having a ComboBox or a ComboList widget.'
   246 'A selector returning a collection of choices for a cell having a ComboBox or a ComboList widget.'
   239 
   247 
   240 #valuesMenuSelector
   248 #valuesMenuSelector
   803      
   811      
   804        #(#FullSpec
   812        #(#FullSpec
   805           #window: 
   813           #window: 
   806            #(#WindowSpec
   814            #(#WindowSpec
   807               #name: 'DataSet Dimension'
   815               #name: 'DataSet Dimension'
   808               #layout: #(#LayoutFrame 216 0 173 0 506 0 416 0)
   816               #layout: #(#LayoutFrame 44 0 255 0 368 0 602 0)
   809               #label: 'DataSet Dimension'
   817               #label: 'DataSet Dimension'
   810               #min: #(#Point 10 10)
   818               #min: #(#Point 10 10)
   811               #max: #(#Point 1280 1024)
   819               #max: #(#Point 1280 1024)
   812               #bounds: #(#Rectangle 216 173 507 417)
   820               #bounds: #(#Rectangle 44 255 369 603)
   813               #usePreferredExtent: false
   821               #usePreferredExtent: false
   814           )
   822           )
   815           #component: 
   823           #component: 
   816            #(#SpecCollection
   824            #(#SpecCollection
   817               #collection: 
   825               #collection: 
   818                #(
   826                #(
   819                  #(#FramedBoxSpec
   827                  #(#FramedBoxSpec
   820                     #name: 'separatorBox'
   828                     #name: 'separatorBox'
   821                     #layout: #(#LayoutFrame 0 0.0 3 0 0 1.0 95 0)
   829                     #layout: #(#LayoutFrame 0 0.0 3 0 0 1.0 132 0)
   822                     #component: 
   830                     #component: 
   823                      #(#SpecCollection
   831                      #(#SpecCollection
   824                         #collection: 
   832                         #collection: 
   825                          #(
   833                          #(
   826                            #(#CheckBoxSpec
   834                            #(#CheckBoxSpec
   829                               #activeHelpKey: #frameShowRowSeparator
   837                               #activeHelpKey: #frameShowRowSeparator
   830                               #tabable: true
   838                               #tabable: true
   831                               #model: #showRowSeparator
   839                               #model: #showRowSeparator
   832                               #label: 'Show Row-Separator'
   840                               #label: 'Show Row-Separator'
   833                           )
   841                           )
       
   842                            #(#InputFieldSpec
       
   843                               #name: 'rowSeparatorSelector'
       
   844                               #layout: #(#LayoutFrame 29 0 41 0 2 1.0 63 0)
       
   845                               #activeHelpKey: #frameShowRowSeparatorSelector
       
   846                               #tabable: true
       
   847                               #model: #rowSeparatorSelector
       
   848                               #type: #symbolOrNil
       
   849                           )
   834                            #(#CheckBoxSpec
   850                            #(#CheckBoxSpec
   835                               #name: 'showColSeparator'
   851                               #name: 'showColSeparator'
   836                               #layout: #(#LayoutFrame 5 0 41 0 181 0 64 0)
   852                               #layout: #(#LayoutFrame 5 0 70 0 181 0 93 0)
   837                               #activeHelpKey: #frameShowColumnSeparator
   853                               #activeHelpKey: #frameShowColumnSeparator
   838                               #tabable: true
   854                               #tabable: true
   839                               #model: #showColSeparator
   855                               #model: #showColSeparator
   840                               #label: 'Show Column-Separator'
   856                               #label: 'Show Column-Separator'
   841                           )
   857                           )
   844                     #label: 'Separators'
   860                     #label: 'Separators'
   845                     #labelPosition: #topLeft
   861                     #labelPosition: #topLeft
   846                 )
   862                 )
   847                  #(#FramedBoxSpec
   863                  #(#FramedBoxSpec
   848                     #name: 'framedBox1'
   864                     #name: 'framedBox1'
   849                     #layout: #(#LayoutFrame 0 0.0 108 0 0 1.0 225 0)
   865                     #layout: #(#LayoutFrame 0 0.0 151 0 0 1.0 268 0)
   850                     #component: 
   866                     #component: 
   851                      #(#SpecCollection
   867                      #(#SpecCollection
   852                         #collection: 
   868                         #collection: 
   853                          #(
   869                          #(
   854                            #(#LabelSpec
   870                            #(#LabelSpec
   902                     #labelPosition: #topLeft
   918                     #labelPosition: #topLeft
   903                 )
   919                 )
   904               )
   920               )
   905           )
   921           )
   906       )
   922       )
   907 
       
   908     "Modified: / 13.8.1998 / 19:54:30 / cg"
       
   909 !
   923 !
   910 
   924 
   911 selectionEditSpec
   925 selectionEditSpec
   912     "This resource specification was automatically generated
   926     "This resource specification was automatically generated
   913      by the UIPainter of ST/X."
   927      by the UIPainter of ST/X."
   926      
   940      
   927        #(#FullSpec
   941        #(#FullSpec
   928           #window: 
   942           #window: 
   929            #(#WindowSpec
   943            #(#WindowSpec
   930               #name: 'DataSet Basic'
   944               #name: 'DataSet Basic'
   931               #layout: #(#LayoutFrame 216 0 173 0 504 0 428 0)
   945               #layout: #(#LayoutFrame 104 0 195 0 434 0 522 0)
   932               #label: 'DataSet Basic'
   946               #label: 'DataSet Basic'
   933               #min: #(#Point 10 10)
   947               #min: #(#Point 10 10)
   934               #max: #(#Point 1280 1024)
   948               #max: #(#Point 1280 1024)
   935               #bounds: #(#Rectangle 216 173 505 429)
   949               #bounds: #(#Rectangle 104 195 435 523)
   936               #usePreferredExtent: false
   950               #usePreferredExtent: false
   937           )
   951           )
   938           #component: 
   952           #component: 
   939            #(#SpecCollection
   953            #(#SpecCollection
   940               #collection: 
   954               #collection: 
   981                     #label: 'Label Select Action:'
   995                     #label: 'Label Select Action:'
   982                     #labelPosition: #topLeft
   996                     #labelPosition: #topLeft
   983                 )
   997                 )
   984                  #(#FramedBoxSpec
   998                  #(#FramedBoxSpec
   985                     #name: 'framedBox2'
   999                     #name: 'framedBox2'
   986                     #layout: #(#LayoutFrame 0 0.0 95 0 0 1.0 178 0)
  1000                     #layout: #(#LayoutFrame 0 0.0 95 0 0 1.0 205 0)
   987                     #component: 
  1001                     #component: 
   988                      #(#SpecCollection
  1002                      #(#SpecCollection
   989                         #collection: 
  1003                         #collection: 
   990                          #(
  1004                          #(
   991                            #(#CheckBoxSpec
  1005                            #(#CheckBoxSpec
   992                               #name: 'canSelect'
  1006                               #name: 'canSelect'
   993                               #layout: #(#Point 95 8)
  1007                               #layout: #(#Point 95 1)
   994                               #activeHelpKey: #selectionIsSelectable
  1008                               #activeHelpKey: #selectionIsSelectable
   995                               #tabable: true
  1009                               #tabable: true
   996                               #model: #canSelect
  1010                               #model: #canSelect
   997                               #label: 'Is Selectable'
  1011                               #label: 'Is Selectable'
   998                           )
  1012                           )
   999                            #(#LabelSpec
  1013                            #(#LabelSpec
  1000                               #name: 'selectorLabel'
  1014                               #name: 'selectorLabel'
  1001                               #layout: #(#AlignmentOrigin 95 0 44 0 1 0.5)
  1015                               #layout: #(#AlignmentOrigin 95 0 37 0 1 0.5)
  1002                               #label: 'Selector:'
  1016                               #label: 'Selector:'
  1003                               #adjust: #right
  1017                               #adjust: #right
  1004                               #resizeForLabel: true
  1018                               #resizeForLabel: true
  1005                           )
  1019                           )
  1006                            #(#InputFieldSpec
  1020                            #(#InputFieldSpec
  1007                               #name: 'selectSelector'
  1021                               #name: 'selectSelector'
  1008                               #layout: #(#LayoutFrame 98 0 33 0 3 1.0 55 0)
  1022                               #layout: #(#LayoutFrame 98 0 26 0 3 1.0 48 0)
  1009                               #activeHelpKey: #selectionCellClickSelector
  1023                               #activeHelpKey: #selectionCellClickSelector
  1010                               #tabable: true
  1024                               #tabable: true
  1011                               #model: #selectSelector
  1025                               #model: #selectSelector
  1012                               #type: #symbolOrNil
  1026                               #type: #symbolOrNil
       
  1027                           )
       
  1028                            #(#CheckBoxSpec
       
  1029                               #name: 'showSelectionHighLightened'
       
  1030                               #layout: #(#LayoutFrame 95 0 53 0 3 1.0 77 0)
       
  1031                               #activeHelpKey: #showSelectionHighLighted
       
  1032                               #tabable: true
       
  1033                               #model: #showSelectionHighLighted
       
  1034                               #label: 'Show Selection HighLightened'
  1013                           )
  1035                           )
  1014                         )
  1036                         )
  1015                     )
  1037                     )
  1016                     #label: 'Cell Selection:'
  1038                     #label: 'Cell Selection:'
  1017                     #labelPosition: #topLeft
  1039                     #labelPosition: #topLeft
  1018                 )
  1040                 )
  1019                  #(#FramedBoxSpec
  1041                  #(#FramedBoxSpec
  1020                     #name: 'framedBox3'
  1042                     #name: 'framedBox3'
  1021                     #layout: #(#LayoutFrame 0 0.0 186 0 0 1.0 243 0)
  1043                     #layout: #(#LayoutFrame 0 0.0 217 0 0 1.0 274 0)
  1022                     #component: 
  1044                     #component: 
  1023                      #(#SpecCollection
  1045                      #(#SpecCollection
  1024                         #collection: 
  1046                         #collection: 
  1025                          #(
  1047                          #(
  1026                            #(#LabelSpec
  1048                            #(#LabelSpec
  1044                     #labelPosition: #topLeft
  1066                     #labelPosition: #topLeft
  1045                 )
  1067                 )
  1046               )
  1068               )
  1047           )
  1069           )
  1048       )
  1070       )
  1049 
       
  1050     "Modified: / 13.8.1998 / 19:54:49 / cg"
       
  1051 !
  1071 !
  1052 
  1072 
  1053 slices
  1073 slices
  1054     ^#(
  1074     ^#(
  1055         (Basics         basicsEditSpec)
  1075         (Basics         basicsEditSpec)
  1760     ].
  1780     ].
  1761     self updateColumnView.
  1781     self updateColumnView.
  1762 
  1782 
  1763 !
  1783 !
  1764 
  1784 
       
  1785 resolveRowClass
       
  1786     "returns the resolved row class
       
  1787     "
       
  1788     ^ Smalltalk resolveName:rowClass inClass:self class
       
  1789 !
       
  1790 
  1765 rowClassName
  1791 rowClassName
  1766 
  1792 
  1767     ^(Smalltalk resolveName:rowClass inClass:self class) notNil ifTrue:[rowClass] ifFalse:[nil]
  1793     ^ self resolveRowClass notNil ifTrue:[rowClass] ifFalse:[nil]
  1768 !
  1794 !
  1769 
  1795 
  1770 rowClassName:aClassName
  1796 rowClassName:aClassName
  1771 
  1797 
  1772     |cls|
  1798     |cls|
  1773 
  1799 
  1774     rowSuperClass := nil.
  1800     rowSuperClass := nil.
  1775 
  1801 
  1776     (rowClass := aClassName) notNil ifTrue:[
  1802     (rowClass := aClassName) notNil ifTrue:[
  1777         (cls := self resolveClassNamed) notNil 
  1803         (cls := self resolveRowClass) notNil 
  1778             ifTrue: [rowSuperClass := cls superclass name asString] 
  1804             ifTrue: [rowSuperClass := cls superclass name asString] 
  1779             ifFalse:[rowSuperClass := 'Object']
  1805             ifFalse:[rowSuperClass := 'Object']
  1780     ]
  1806     ]
  1781 
  1807 
  1782 ! !
  1808 ! !
  2004 
  2030 
  2005     catg := 'accessing menu' asSymbol.
  2031     catg := 'accessing menu' asSymbol.
  2006     code :=   '\'
  2032     code :=   '\'
  2007             , '    "automatically generated by DataSetBuilder ..."\'
  2033             , '    "automatically generated by DataSetBuilder ..."\'
  2008             , '\'
  2034             , '\'
  2009             , '    "get choices for visual editor; (a list of labels)\'
  2035             , '    "get choices for visual editor; (a list of labels)..."\'
  2010             , '\'
  2036             , '\'
  2011             , '    ^nil'
  2037             , '    ^ #( foo bar baz )'
  2012             .
  2038             .
  2013 
  2039 
  2014     columns do:
  2040     columns do:
  2015     [:aColumn|
  2041     [:aColumn|
  2016         (aColumn canSelect
  2042         (aColumn canSelect
  2163             ]
  2189             ]
  2164         ]
  2190         ]
  2165     ]
  2191     ]
  2166 !
  2192 !
  2167 
  2193 
       
  2194 generateRowSeparatorSelectorIn:aClass
       
  2195     "generate code for #rowSeparatorSelector"
       
  2196 
       
  2197     |sel catg code bCode|
       
  2198 
       
  2199     catg := 'accessing look' asSymbol.
       
  2200     code :=   '\'
       
  2201             , '    "automatically generated by DataSetBuilder ..."\'
       
  2202             , '\'
       
  2203             , '    "specific row separator visibility for a cell"\'
       
  2204             , '\'
       
  2205             .
       
  2206 
       
  2207     columns do:
       
  2208     [:aColumn|
       
  2209         ((sel := aColumn rowSeparatorSelector) notNil and:[(aClass implements:sel) not]) 
       
  2210         ifTrue:
       
  2211         [
       
  2212             bCode := sel asString, code, '    ^true'.
       
  2213             self compile:bCode forClass:aClass inCategory:catg
       
  2214         ]
       
  2215     ]
       
  2216 
       
  2217 
       
  2218 !
       
  2219 
  2168 generateSelectSelectorIn:aClass
  2220 generateSelectSelectorIn:aClass
  2169     "generate code for #selectSelector
  2221     "generate code for #selectSelector
  2170     "
  2222     "
  2171     |sel catg code bCode|
  2223     |sel catg code bCode|
  2172 
  2224 
  2208             .
  2260             .
  2209 
  2261 
  2210     columns do:
  2262     columns do:
  2211     [:aColumn|
  2263     [:aColumn|
  2212         ((sel := aColumn writeSelector) notNil
  2264         ((sel := aColumn writeSelector) notNil
       
  2265          and:[aColumn editorType ~~ #None
  2213          and:[aColumn canSelect
  2266          and:[aColumn canSelect
  2214          and:[(aClass implements:sel) not]]) 
  2267          and:[(aClass implements:sel) not]]]) 
  2215         ifTrue:
  2268         ifTrue:
  2216         [
  2269         [
  2217             sel numArgs == 1 
  2270             sel numArgs == 1 
  2218             ifTrue:
  2271             ifTrue:
  2219             [
  2272             [
  2279             [:column| 
  2332             [:column| 
  2280                 column readSelector:  #at:;
  2333                 column readSelector:  #at:;
  2281                     writeSelector: #at:put:;
  2334                     writeSelector: #at:put:;
  2282                     backgroundSelector:nil;
  2335                     backgroundSelector:nil;
  2283                     foregroundSelector:nil;
  2336                     foregroundSelector:nil;
       
  2337                     rowSeparatorSelector:nil;
  2284                     selectSelector: nil;
  2338                     selectSelector: nil;
  2285                     doubleClickedSelector: nil;
  2339                     doubleClickedSelector: nil;
  2286                     printSelector: nil;
  2340                     printSelector: nil;
  2287                     menu: nil;
  2341                     menu: nil;
  2288                     choices: nil
  2342                     choices: nil
  2446 doBrowseRowClass
  2500 doBrowseRowClass
  2447     "browse class of columns spec"
  2501     "browse class of columns spec"
  2448 
  2502 
  2449     |cls|
  2503     |cls|
  2450 
  2504 
  2451     (cls := self resolveClassNamed) notNil 
  2505     (cls := self resolveRowClass) notNil 
  2452         ifTrue: [SystemBrowser openInClass:cls] 
  2506         ifTrue: [SystemBrowser openInClass:cls] 
  2453         ifFalse:[self information:'No class defined !!']
  2507         ifFalse:[self information:'No class defined !!']
  2454 
  2508 
  2455     "Modified: / 20.5.1998 / 03:48:04 / cg"
  2509     "Modified: / 20.5.1998 / 03:48:04 / cg"
  2456 !
  2510 !
  2517     whileTrue:
  2571     whileTrue:
  2518     [
  2572     [
  2519         rowClass notNil 
  2573         rowClass notNil 
  2520         ifTrue:
  2574         ifTrue:
  2521         [
  2575         [
  2522             (cls := self resolveClassNamed) notNil 
  2576             (cls := self resolveRowClass) notNil 
  2523             ifTrue:
  2577             ifTrue:
  2524             [
  2578             [
  2525                 rowSuperClass := cls superclass name asString
  2579                 rowSuperClass := cls superclass name asString
  2526             ].
  2580             ].
  2527             aspects at:#classNameChannel put:(ValueHolder with:rowClass)
  2581             aspects at:#classNameChannel put:(ValueHolder with:rowClass)
  2551             rowClass := nil.
  2605             rowClass := nil.
  2552             self information:'no valid className'
  2606             self information:'no valid className'
  2553         ] 
  2607         ] 
  2554         ifFalse: 
  2608         ifFalse: 
  2555         [
  2609         [
  2556             cls := self resolveClassNamed.
  2610             cls := self resolveRowClass.
  2557 
  2611 
  2558             cls notNil ifTrue:[cls := cls superclass name asString].
  2612             cls notNil ifTrue:[cls := cls superclass name asString].
  2559 
  2613 
  2560             rowSuperClass size == 0 
  2614             rowSuperClass size == 0 
  2561             ifTrue:
  2615             ifTrue:
  2606     "generate code for column values"
  2660     "generate code for column values"
  2607 
  2661 
  2608     |cls superclass|
  2662     |cls superclass|
  2609 
  2663 
  2610     rowClass isNil ifTrue:[^self information:'No class defined!!'].
  2664     rowClass isNil ifTrue:[^self information:'No class defined!!'].
  2611     cls := self resolveClassNamed.
  2665     cls := self resolveRowClass.
  2612 
  2666 
  2613     cls isNil 
  2667     cls isNil 
  2614     ifTrue:
  2668     ifTrue:
  2615     [
  2669     [
  2616         superclass := Smalltalk resolveName:rowSuperClass inClass:self class.
  2670         superclass := Smalltalk resolveName:rowSuperClass inClass:self class.
  2631     self generateBackgroundSelectorIn:cls.
  2685     self generateBackgroundSelectorIn:cls.
  2632     self generateForegroundSelectorIn:cls.
  2686     self generateForegroundSelectorIn:cls.
  2633     self generateSelectSelectorIn:cls.
  2687     self generateSelectSelectorIn:cls.
  2634     self generateWriteSelectorIn:cls.
  2688     self generateWriteSelectorIn:cls.
  2635     self generateDoubleClickSelectorIn:cls.
  2689     self generateDoubleClickSelectorIn:cls.
       
  2690     self generateRowSeparatorSelectorIn:cls.
  2636 !
  2691 !
  2637 
  2692 
  2638 doMoveColumn:upOrDown
  2693 doMoveColumn:upOrDown
  2639     "move selected column up or down"
  2694     "move selected column up or down"
  2640 
  2695 
  2707     |cls dst spc idx category mthd excla code resourceType|
  2762     |cls dst spc idx category mthd excla code resourceType|
  2708 
  2763 
  2709     (columns size ~~ 0 and:[super doSave]) ifFalse:[
  2764     (columns size ~~ 0 and:[super doSave]) ifFalse:[
  2710         ^ nil
  2765         ^ nil
  2711     ].
  2766     ].
       
  2767 
  2712     cls := self resolveName:specClass.
  2768     cls := self resolveName:specClass.
  2713     dst := columns collect:[:aCol| aCol literalArrayEncoding ].
  2769     dst := columns collect:[:aCol| aCol literalArrayEncoding ].
  2714     spc := WriteStream on:String new.
  2770     spc := WriteStream on:String new.
  2715     UISpecification prettyPrintSpecArray:dst asArray on:spc indent:4.
  2771     UISpecification prettyPrintSpecArray:dst asArray on:spc indent:4.
  2716     spc := spc contents.
  2772     spc := spc contents.