DataSetBuilder.st
changeset 818 5bd68980f09a
parent 817 d350f49ae748
child 825 89719cf96c63
equal deleted inserted replaced
817:d350f49ae748 818:5bd68980f09a
    12 
    12 
    13 
    13 
    14 
    14 
    15 
    15 
    16 
    16 
    17 ToolApplicationModel subclass:#DataSetBuilder
    17 ResourceSpecEditor subclass:#DataSetBuilder
    18 	instanceVariableNames:'className superclassName hasChanged columnView columns
    18 	instanceVariableNames:'rowClass rowSuperClass hasChanged columnView columns
    19 		selectedColumnIndex tabSelectionIndex aspects'
    19 		selectedColumnIndex tabSelectionIndex'
    20 	classVariableNames:''
    20 	classVariableNames:''
    21 	poolDictionaries:''
    21 	poolDictionaries:''
    22 	category:'Interface-UIPainter'
    22 	category:'Interface-UIPainter'
    23 !
    23 !
    24 
    24 
    59 ! !
    59 ! !
    60 
    60 
    61 !DataSetBuilder class methodsFor:'instance creation'!
    61 !DataSetBuilder class methodsFor:'instance creation'!
    62 
    62 
    63 openOnClass:aClass andSelector:aSelector
    63 openOnClass:aClass andSelector:aSelector
    64     self information:'not yet implemented'
    64 
    65 
    65     ^ self new openOnClass:aClass andSelector:aSelector
    66     "Created: / 22.4.1998 / 10:21:03 / cg"
       
    67 ! !
    66 ! !
    68 
    67 
       
    68 !DataSetBuilder class methodsFor:'constants'!
       
    69 
       
    70 resourceType
       
    71     "get the type of resource of the method generated by the MenuEditor"
       
    72 
       
    73     ^#dataset
       
    74 
       
    75 
       
    76 ! !
       
    77 
    69 !DataSetBuilder class methodsFor:'help specs'!
    78 !DataSetBuilder class methodsFor:'help specs'!
    70 
    79 
    71 helpSpec
    80 helpSpec
    72     "return a dictionary filled with helpKey -> helptext associations.
    81     "This resource specification was automatically generated
    73      These are used by the activeHelp tool."
    82      by the UIHelpTool of ST/X."
    74 
    83 
    75     "
    84     "Do not manually edit this!! If it is corrupted,
    76     UIHelpTool openOnClass:DataSetBuilder    
    85      the UIHelpTool may not be able to read the specification."
    77     "
    86 
    78 
    87     "
    79   ^ super helpSpec addPairsFrom:#(
    88      UIHelpTool openOnClass:DataSetBuilder    
       
    89     "
       
    90 
       
    91     <resource: #help>
       
    92 
       
    93     ^super helpSpec addPairsFrom:#(
    80 
    94 
    81 #addColumn
    95 #addColumn
    82 'Adds a new column.'
    96 'Adds a new column.'
    83 
    97 
    84 #basicsEditor
    98 #basicsEditor
   140 
   154 
   141 #frameShowRowSeparator
   155 #frameShowRowSeparator
   142 'Turns on/off displaying row separators.'
   156 'Turns on/off displaying row separators.'
   143 
   157 
   144 #selectionCellClickSelector
   158 #selectionCellClickSelector
   145 'A selector called if cell was selected. '
   159 'A selector called if cell was selected.'
   146 
   160 
   147 #selectionCellDoubleClickSelector
   161 #selectionCellDoubleClickSelector
   148 'A selector called if cell was double clicked.'
   162 'A selector called if cell was double clicked.'
   149 
   163 
   150 #selectionCellSelector
   164 #selectionCellSelector
   155 
   169 
   156 #selectionLabelClickSelector
   170 #selectionLabelClickSelector
   157 'A selector called if label cell was clicked.'
   171 'A selector called if label cell was clicked.'
   158 
   172 
   159 #selectionLabelSelectorArgument
   173 #selectionLabelSelectorArgument
   160 'An argument passed to label selection selector. '
   174 'An argument passed to label selection selector.'
   161 
   175 
   162 #valuesChoiceSelector
   176 #valuesChoiceSelector
   163 'A selector returning a collection of choices for a cell having a ComboBox or a ComboList widget.'
   177 'A selector returning a collection of choices for a cell having a ComboBox or a ComboList widget.'
   164 
   178 
   165 #valuesMenuSelector
   179 #valuesMenuSelector
  1089      
  1103      
  1090        #(#FullSpec
  1104        #(#FullSpec
  1091           #window: 
  1105           #window: 
  1092            #(#WindowSpec
  1106            #(#WindowSpec
  1093               #name: 'Data Set Builder'
  1107               #name: 'Data Set Builder'
  1094               #layout: #(#LayoutFrame 662 0 70 0 1132 0 446 0)
  1108               #layout: #(#LayoutFrame 487 0 189 0 1031 0 690 0)
  1095               #label: 'Data Set Builder'
  1109               #label: 'Data Set Builder'
  1096               #min: #(#Point 10 10)
  1110               #min: #(#Point 10 10)
  1097               #max: #(#Point 1152 900)
  1111               #max: #(#Point 1152 900)
  1098               #bounds: #(#Rectangle 662 70 1133 447)
  1112               #bounds: #(#Rectangle 487 189 1032 691)
  1099               #menu: #menu
  1113               #menu: #menu
  1100               #usePreferredExtent: false
  1114               #usePreferredExtent: false
  1101           )
  1115           )
  1102           #component: 
  1116           #component: 
  1103            #(#SpecCollection
  1117            #(#SpecCollection
  1104               #collection: 
  1118               #collection: 
  1105                #(
  1119                #(
  1106                  #(#MenuPanelSpec
  1120                  #(#ViewSpec
  1107                     #name: 'menuToolbarView'
  1121                     #name: 'Box1'
  1108                     #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 32 0)
  1122                     #layout: #(#LayoutFrame 0 0.0 100 0.0 0 1.0 0 1.0)
  1109                     #menu: #menuToolbar
       
  1110                 )
       
  1111                  #(#VariableHorizontalPanelSpec
       
  1112                     #name: 'VariablePanel'
       
  1113                     #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
       
  1114                     #component: 
  1123                     #component: 
  1115                      #(#SpecCollection
  1124                      #(#SpecCollection
  1116                         #collection: 
  1125                         #collection: 
  1117                          #(
  1126                          #(
  1118                            #(#ViewSpec
  1127                            #(#MenuPanelSpec
  1119                               #name: 'labelsView'
  1128                               #name: 'menuToolbarView'
       
  1129                               #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 32 0)
       
  1130                               #menu: #menuToolbar
       
  1131                           )
       
  1132                            #(#VariableHorizontalPanelSpec
       
  1133                               #name: 'VariablePanel'
       
  1134                               #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
  1120                               #component: 
  1135                               #component: 
  1121                                #(#SpecCollection
  1136                                #(#SpecCollection
  1122                                   #collection: 
  1137                                   #collection: 
  1123                                    #(
  1138                                    #(
  1124                                      #(#SequenceViewSpec
  1139                                      #(#ViewSpec
  1125                                         #name: 'columnView'
  1140                                         #name: 'labelsView'
  1126                                         #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1141                                         #component: 
  1127                                         #model: #selectedColumnModel
  1142                                          #(#SpecCollection
  1128                                         #menu: #menuEdit
  1143                                             #collection: 
  1129                                         #hasHorizontalScrollBar: true
  1144                                              #(
  1130                                         #hasVerticalScrollBar: true
  1145                                                #(#SequenceViewSpec
  1131                                         #miniScrollerHorizontal: true
  1146                                                   #name: 'labelAndColumns'
  1132                                         #useIndex: true
  1147                                                   #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1133                                         #sequenceList: #seqList
  1148                                                   #model: #selectedColumnModel
       
  1149                                                   #menu: #menuEdit
       
  1150                                                   #hasHorizontalScrollBar: true
       
  1151                                                   #hasVerticalScrollBar: true
       
  1152                                                   #miniScrollerHorizontal: true
       
  1153                                                   #useIndex: true
       
  1154                                                   #sequenceList: #seqList
       
  1155                                               )
       
  1156                                             )
       
  1157                                         )
       
  1158                                     )
       
  1159                                      #(#ViewSpec
       
  1160                                         #name: 'specView'
       
  1161                                         #component: 
       
  1162                                          #(#SpecCollection
       
  1163                                             #collection: 
       
  1164                                              #(
       
  1165                                                #(#TabViewSpec
       
  1166                                                   #name: 'tabView'
       
  1167                                                   #layout: #(#LayoutFrame 1 0.0 0 0 0 1.0 35 0)
       
  1168                                                   #model: #tabModel
       
  1169                                                   #menu: #tabList
       
  1170                                                   #useIndex: true
       
  1171                                               )
       
  1172                                                #(#SubCanvasSpec
       
  1173                                                   #name: 'specCanvas'
       
  1174                                                   #layout: #(#LayoutFrame 1 0.0 35 0.0 0 1.0 -30 1.0)
       
  1175                                                   #specHolder: #specChannel
       
  1176                                               )
       
  1177                                                #(#UISubSpecification
       
  1178                                                   #name: 'SubSpecification'
       
  1179                                                   #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0)
       
  1180                                                   #majorKey: #ToolApplicationModel
       
  1181                                                   #minorKey: #windowSpecForCommit
       
  1182                                               )
       
  1183                                             )
       
  1184                                         )
       
  1185                                         #level: -1
  1134                                     )
  1186                                     )
  1135                                   )
  1187                                   )
  1136                               )
  1188                               )
  1137                           )
  1189                               #handles: #(#Any 0.346072 1.0)
  1138                            #(#ViewSpec
  1190                           )
  1139                               #name: 'specView'
  1191                            #(#UISubSpecification
  1140                               #component: 
  1192                               #name: 'infoBarSubSpec'
  1141                                #(#SpecCollection
  1193                               #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
  1142                                   #collection: 
  1194                               #majorKey: #ToolApplicationModel
  1143                                    #(
  1195                               #minorKey: #windowSpecForInfoBar
  1144                                      #(#TabViewSpec
       
  1145                                         #name: 'tabView'
       
  1146                                         #layout: #(#LayoutFrame 1 0.0 0 0 0 1.0 35 0)
       
  1147                                         #model: #tabModel
       
  1148                                         #menu: #tabList
       
  1149                                         #useIndex: true
       
  1150                                     )
       
  1151                                      #(#SubCanvasSpec
       
  1152                                         #name: 'specCanvas'
       
  1153                                         #layout: #(#LayoutFrame 1 0.0 35 0.0 0 1.0 -30 1.0)
       
  1154                                         #specHolder: #specChannel
       
  1155                                     )
       
  1156                                      #(#UISubSpecification
       
  1157                                         #name: 'SubSpecification'
       
  1158                                         #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1.0)
       
  1159                                         #majorKey: #ToolApplicationModel
       
  1160                                         #minorKey: #windowSpecForCommit
       
  1161                                     )
       
  1162                                   )
       
  1163                               )
       
  1164                               #level: -1
       
  1165                           )
  1196                           )
  1166                         )
  1197                         )
  1167                     )
  1198                     )
  1168                     #handles: #(#Any 0.265905 1.0)
       
  1169                 )
  1199                 )
  1170                  #(#UISubSpecification
  1200                  #(#FramedBoxSpec
  1171                     #name: 'infoBarSubSpec'
  1201                     #name: 'ColumnFrame'
  1172                     #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
  1202                     #layout: #(#LayoutFrame 0 0.0 5 0.0 0 1.0 100 0)
  1173                     #majorKey: #ToolApplicationModel
  1203                     #component: 
  1174                     #minorKey: #windowSpecForInfoBar
  1204                      #(#SpecCollection
       
  1205                         #collection: 
       
  1206                          #(
       
  1207                            #(#DataSetSpec
       
  1208                               #name: 'columnView'
       
  1209                               #layout: #(#LayoutFrame 14 0.0 18 0.0 14 1.0 14 1.0)
       
  1210                               #hasHorizontalScrollBar: true
       
  1211                               #hasVerticalScrollBar: false
       
  1212                               #miniScrollerHorizontal: true
       
  1213                               #rowClassName: 'CodingExamples_GUI::GUIDemoDataSetView::Row'
       
  1214                               #useIndex: false
       
  1215                               #has3Dsepartors: true
       
  1216                           )
       
  1217                         )
       
  1218                     )
       
  1219                     #label: 'Table Columns'
       
  1220                     #labelPosition: #topLeft
  1175                 )
  1221                 )
  1176               )
  1222               )
  1177           )
  1223           )
  1178       )
  1224       )
  1179 ! !
  1225 ! !
  1180 
  1226 
  1181 !DataSetBuilder class methodsFor:'menu specs'!
  1227 !DataSetBuilder class methodsFor:'menu specs'!
  1182 
  1228 
  1183 menu
  1229 menu
  1184     "this window spec was automatically generated by the ST/X MenuEditor"
  1230     "This resource specification was automatically generated
  1185 
  1231      by the MenuEditor of ST/X."
  1186     "do not manually edit this - the builder may not be able to
  1232 
  1187      handle the specification if its corrupted."
  1233     "Do not manually edit this!! If it is corrupted,
       
  1234      the MenuEditor may not be able to read the specification."
  1188 
  1235 
  1189     "
  1236     "
  1190      MenuEditor new openOnClass:DataSetBuilder andSelector:#menu
  1237      MenuEditor new openOnClass:DataSetBuilder andSelector:#menu
  1191      (Menu new fromLiteralArrayEncoding:(DataSetBuilder menu)) startUp
  1238      (Menu new fromLiteralArrayEncoding:(DataSetBuilder menu)) startUp
  1192     "
  1239     "
  1197      
  1244      
  1198        #(#Menu
  1245        #(#Menu
  1199           
  1246           
  1200            #(
  1247            #(
  1201              #(#MenuItem
  1248              #(#MenuItem
  1202                 #'label:' 'About'
  1249                 #label: 'About'
  1203                 #'activeHelpKey:' #about
  1250                 #accessCharacterPosition: 1
  1204                 #'labelImage:' #(#ResourceRetriever nil #menuIcon)
  1251                 #labelImage: #(#ResourceRetriever nil #menuIcon)
  1205                 #'submenuChannel:' #menuAbout
  1252                 #submenuChannel: #menuAbout
  1206             )
  1253             )
  1207              #(#MenuItem
  1254              #(#MenuItem
  1208                 #'label:' 'File'
  1255                 #label: 'File'
  1209                 #'activeHelpKey:' #file
  1256                 #activeHelpKey: #file
  1210                 #'submenu:' 
  1257                 #submenu: 
  1211                  #(#Menu
  1258                  #(#Menu
  1212                     
  1259                     
  1213                      #(
  1260                      #(
  1214                        #(#MenuItem
  1261                        #(#MenuItem
  1215                           #'label:' 'Generate Code'
  1262                           #label: 'New'
  1216                           #'value:' #doGenerateCode
  1263                           #value: #doNew
       
  1264                           #activeHelpKey: #fileNew
  1217                       )
  1265                       )
  1218                        #(#MenuItem
  1266                        #(#MenuItem
  1219                           #'label:' '-'
  1267                           #label: '-'
  1220                       )
  1268                       )
  1221                        #(#MenuItem
  1269                        #(#MenuItem
  1222                           #'label:' 'Define Class...'
  1270                           #label: 'Load...'
  1223                           #'value:' #doDefineClass
  1271                           #translateLabel: true
  1224                           #'activeHelpKey:' #fileDefineClass
  1272                           #value: #doLoad
       
  1273                           #activeHelpKey: #fileLoad
  1225                       )
  1274                       )
  1226                        #(#MenuItem
  1275                        #(#MenuItem
  1227                           #'label:' 'Browse Class'
  1276                           #label: '-'
  1228                           #'value:' #doBrowseClass
       
  1229                           #'activeHelpKey:' #fileBrowseClass
       
  1230                       )
  1277                       )
  1231                        #(#MenuItem
  1278                        #(#MenuItem
  1232                           #'label:' '-'
  1279                           #label: 'Save'
       
  1280                           #value: #doSave
       
  1281                           #activeHelpKey: #fileSave
  1233                       )
  1282                       )
  1234                        #(#MenuItem
  1283                        #(#MenuItem
  1235                           #'label:' 'Exit'
  1284                           #label: 'Save As...'
  1236                           #'value:' #closeRequest
  1285                           #value: #doSaveAs
  1237                           #'activeHelpKey:' #fileExit
  1286                           #activeHelpKey: #fileSaveAs
       
  1287                       )
       
  1288                        #(#MenuItem
       
  1289                           #label: '-'
       
  1290                       )
       
  1291                        #(#MenuItem
       
  1292                           #label: 'Pick Columns...'
       
  1293                           #value: #doPickColumns
       
  1294                       )
       
  1295                        #(#MenuItem
       
  1296                           #label: '-'
       
  1297                       )
       
  1298                        #(#MenuItem
       
  1299                           #label: 'Browse Class'
       
  1300                           #value: #doBrowseClass
       
  1301                           #activeHelpKey: #fileBrowseClass
       
  1302                       )
       
  1303                        #(#MenuItem
       
  1304                           #label: '-'
       
  1305                       )
       
  1306                        #(#MenuItem
       
  1307                           #label: 'Exit'
       
  1308                           #translateLabel: true
       
  1309                           #value: #closeRequest
       
  1310                           #activeHelpKey: #fileExit
  1238                       )
  1311                       )
  1239                     ) nil
  1312                     ) nil
  1240                     nil
  1313                     nil
  1241                 )
  1314                 )
  1242             )
  1315             )
  1243              #(#MenuItem
  1316              #(#MenuItem
  1244                 #'label:' 'Edit'
  1317                 #label: 'Edit'
  1245                 #'activeHelpKey:' #edit
  1318                 #activeHelpKey: #edit
  1246                 #'submenuChannel:' #menuEdit
  1319                 #submenuChannel: #menuEdit
  1247             )
  1320             )
  1248              #(#MenuItem
  1321              #(#MenuItem
  1249                 #'label:' 'Add'
  1322                 #label: 'Add'
  1250                 #'activeHelpKey:' #add
  1323                 #submenu: 
  1251                 #'submenu:' 
       
  1252                  #(#Menu
  1324                  #(#Menu
  1253                     
  1325                     
  1254                      #(
  1326                      #(
  1255                        #(#MenuItem
  1327                        #(#MenuItem
  1256                           #'label:' 'Column'
  1328                           #label: 'Column'
  1257                           #'value:' #doCreateColumn
  1329                           #value: #doCreateColumn
  1258                           #'activeHelpKey:' #addColumn
  1330                           #activeHelpKey: #addColumn
  1259                           #'enabled:' #columnIsNotEditing
  1331                           #enabled: #columnIsNotEditing
  1260                           #'labelImage:' #(#ResourceRetriever nil #newColumnIcon 'Column')
  1332                           #labelImage: #(#ResourceRetriever nil #newColumnIcon)
  1261                       )
  1333                       )
  1262                     ) nil
  1334                     ) nil
  1263                     nil
  1335                     nil
  1264                 )
  1336                 )
  1265             )
  1337             )
  1266              #(#MenuItem
  1338              #(#MenuItem
  1267                 #'label:' 'Help'
  1339                 #label: 'Generate'
  1268                 #'startGroup:' #right
  1340                 #activeHelpKey: #file
  1269                 #'activeHelpKey:' #help
  1341                 #submenu: 
  1270                 #'submenuChannel:' #menuHelp
  1342                  #(#Menu
       
  1343                     
       
  1344                      #(
       
  1345                        #(#MenuItem
       
  1346                           #label: 'Define Row Class...'
       
  1347                           #value: #doDefineRowClass
       
  1348                           #activeHelpKey: #fileDefineClass
       
  1349                       )
       
  1350                        #(#MenuItem
       
  1351                           #label: 'Browse Row Class'
       
  1352                           #value: #doBrowseRowClass
       
  1353                       )
       
  1354                        #(#MenuItem
       
  1355                           #label: '-'
       
  1356                       )
       
  1357                        #(#MenuItem
       
  1358                           #label: 'Generate Code'
       
  1359                           #value: #doGenerateCode
       
  1360                       )
       
  1361                     ) nil
       
  1362                     nil
       
  1363                 )
       
  1364             )
       
  1365              #(#MenuItem
       
  1366                 #label: 'History'
       
  1367                 #activeHelpKey: #history
       
  1368                 #submenuChannel: #menuHistory
       
  1369             )
       
  1370              #(#MenuItem
       
  1371                 #label: 'Help'
       
  1372                 #startGroup: #right
       
  1373                 #submenu: 
       
  1374                  #(#Menu
       
  1375                     
       
  1376                      #(
       
  1377                        #(#MenuItem
       
  1378                           #label: 'Documentation'
       
  1379                           #value: #openHTMLDocument:
       
  1380                           #activeHelpKey: #helpTutorial
       
  1381                           #argument: 'tools/uipainter/DataSetBuilder.html'
       
  1382                       )
       
  1383                        #(#MenuItem
       
  1384                           #label: '-'
       
  1385                       )
       
  1386                        #(#MenuItem
       
  1387                           #label: 'Help Tool'
       
  1388                           #value: #openHTMLDocument:
       
  1389                           #activeHelpKey: #helpHelpTool
       
  1390                           #argument: 'tools/uipainter/HelpTool.html'
       
  1391                       )
       
  1392                        #(#MenuItem
       
  1393                           #label: '-'
       
  1394                       )
       
  1395                        #(#MenuItem
       
  1396                           #label: 'Show Help Texts'
       
  1397                           #activeHelpKey: #helpShowHelp
       
  1398                           #indication: #showHelp:
       
  1399                       )
       
  1400                     ) nil
       
  1401                     nil
       
  1402                 )
  1271             )
  1403             )
  1272           ) nil
  1404           ) nil
  1273           nil
  1405           nil
  1274       )
  1406       )
  1275 !
  1407 !
  1403 !DataSetBuilder methodsFor:'accessing'!
  1535 !DataSetBuilder methodsFor:'accessing'!
  1404 
  1536 
  1405 columns
  1537 columns
  1406     "returns list of columns"
  1538     "returns list of columns"
  1407 
  1539 
  1408     ^columns
  1540     ^ columns
  1409 !
  1541 !
  1410 
  1542 
  1411 columns:aListOfColumns fromView:aColumnView
  1543 columns:aListOfColumns
  1412     "setup columns from a column view"
  1544     "setup columns from a column view"
  1413 
  1545 
  1414     |list|
  1546     |list|
  1415 
  1547 
  1416     columnView := aColumnView.
       
  1417     columns    := OrderedCollection new.
  1548     columns    := OrderedCollection new.
  1418     list       := self seqList.
  1549     list       := self seqList.
  1419     hasChanged := false.
  1550     hasChanged := false.
  1420 
  1551 
  1421     list removeAll.
  1552     list removeAll.
  1422 
  1553 
  1423     aListOfColumns size ~~ 0 
  1554     aListOfColumns size ~~ 0 ifTrue:[
  1424     ifTrue:
  1555         aListOfColumns do:[:aColumn||column|
  1425     [
  1556             (column := aColumn) isSequenceable ifTrue:[
  1426         aListOfColumns do:
  1557                 column := DataSetColumnSpec new fromLiteralArrayEncoding:aColumn
  1427         [:aColumn|
  1558             ] ifFalse:[
  1428             columns add: aColumn copy.
  1559                 column := aColumn copy
  1429             aColumn rendererType == #rowSelector 
  1560             ].
  1430                 ifFalse:[list add: aColumn label]
  1561             columns add:column.
  1431                 ifTrue: [list add:'Row Selector']
  1562             list add:(self labelFromColumn:column).
  1432         ]
  1563         ]
  1433     ]
  1564     ].
       
  1565     self updateColumnView.
       
  1566 
  1434 !
  1567 !
  1435 
  1568 
  1436 rowClassName
  1569 rowClassName
  1437 
  1570 
  1438     ^(Smalltalk resolveName:className inClass:self class) notNil ifTrue:[className] ifFalse:[nil]
  1571     ^(Smalltalk resolveName:rowClass inClass:self class) notNil ifTrue:[rowClass] ifFalse:[nil]
  1439 !
  1572 !
  1440 
  1573 
  1441 rowClassName:aClassName
  1574 rowClassName:aClassName
  1442 
  1575 
  1443     |cls|
  1576     |cls|
  1444 
  1577 
  1445     superclassName := nil.
  1578     rowSuperClass := nil.
  1446 
  1579 
  1447     (className := aClassName) notNil 
  1580     (rowClass := aClassName) notNil ifTrue:[
  1448     ifTrue:
  1581         (cls := self resolveRowClassNamed) notNil 
  1449     [
  1582             ifTrue: [rowSuperClass := cls superclass name asString] 
  1450         (cls := self resolveClassNamed) notNil 
  1583             ifFalse:[rowSuperClass := 'Object']
  1451             ifTrue: [superclassName := cls superclass name asString] 
       
  1452             ifFalse:[superclassName := 'Object']
       
  1453     ]
  1584     ]
  1454 
  1585 
  1455 ! !
  1586 ! !
  1456 
  1587 
  1457 !DataSetBuilder methodsFor:'aspects'!
  1588 !DataSetBuilder methodsFor:'aspects'!
  1582     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
  1713     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
  1583         holder := AspectAdaptor new subject:self; forAspect:#tabSelectionIndex.
  1714         holder := AspectAdaptor new subject:self; forAspect:#tabSelectionIndex.
  1584         builder aspectAt:#tabModel put:holder.
  1715         builder aspectAt:#tabModel put:holder.
  1585     ].
  1716     ].
  1586     ^ holder
  1717     ^ holder
       
  1718 ! !
       
  1719 
       
  1720 !DataSetBuilder methodsFor:'building'!
       
  1721 
       
  1722 buildFromClass:aClass andSelector:aSelector
       
  1723     |cls list|
       
  1724 
       
  1725     list := nil.
       
  1726 
       
  1727     (aClass notNil or:[self isStandAlone or:[self window shown]]) ifTrue:[
       
  1728 
       
  1729         (aClass notNil and:[aSelector notNil]) ifTrue:[
       
  1730             cls := self resolveName:aClass.
       
  1731 
       
  1732             (cls respondsTo:aSelector) ifTrue:[
       
  1733                 list := cls perform:aSelector        
       
  1734             ]
       
  1735         ]
       
  1736     ] ifFalse:[
       
  1737         list := columns
       
  1738     ].
       
  1739     self columns:list
       
  1740 !
       
  1741 
       
  1742 buildFromResourceSpec:aResourceSpec
       
  1743 
       
  1744     self columns:aResourceSpec
  1587 ! !
  1745 ! !
  1588 
  1746 
  1589 !DataSetBuilder methodsFor:'change & update'!
  1747 !DataSetBuilder methodsFor:'change & update'!
  1590 
  1748 
  1591 update:something with:aParameter from:someObject
  1749 update:something with:aParameter from:someObject
  1872 
  2030 
  1873     super initialize.
  2031     super initialize.
  1874     selectedColumnIndex := 0.
  2032     selectedColumnIndex := 0.
  1875     tabSelectionIndex   := 0.
  2033     tabSelectionIndex   := 0.
  1876     columns := OrderedCollection new.
  2034     columns := OrderedCollection new.
  1877     aspects := IdentityDictionary new.
       
  1878     hasChanged := false.
  2035     hasChanged := false.
  1879 
  2036 
  1880     #(
  2037     #(
  1881         label
  2038         label
  1882         canSelect
  2039         canSelect
  1933     ].
  2090     ].
  1934     ^true
  2091     ^true
  1935 
  2092 
  1936 !
  2093 !
  1937 
  2094 
  1938 resolveClassNamed
  2095 labelFromColumn:aColumn
       
  2096     ^ aColumn rendererType == #rowSelector ifFalse:[aColumn label]
       
  2097                                             ifTrue:['Row Selector'].
       
  2098 !
       
  2099 
       
  2100 resolveRowClassNamed
  1939     "returns current class or nil"
  2101     "returns current class or nil"
  1940 
  2102 
  1941     ^Smalltalk resolveName:className inClass:self class.
  2103     ^Smalltalk resolveName:rowClass inClass:self class.
  1942 
  2104 
  1943 !
  2105 !
  1944 
  2106 
  1945 updateColumnView
  2107 updateColumnView
  1946     "update column view from column descriptions"
  2108     "update column view from column descriptions"
  1947 
       
  1948     columnView notNil ifTrue:[columnView columnDescriptors:columns]
  2109     columnView notNil ifTrue:[columnView columnDescriptors:columns]
  1949 !
  2110 !
  1950 
  2111 
  1951 updateInputFields
  2112 updateInputFields
  1952     "reload item value into input fields"
  2113     "reload item value into input fields"
  2037     self checkMenuItemModified ifTrue: [super closeRequest]
  2198     self checkMenuItemModified ifTrue: [super closeRequest]
  2038 !
  2199 !
  2039 
  2200 
  2040 postBuildWith:builder
  2201 postBuildWith:builder
  2041 
  2202 
       
  2203     columnView := self builder componentAt:#columnView.
       
  2204     columnView labelView enabled:false.
       
  2205 
  2042     super postBuildWith:builder.
  2206     super postBuildWith:builder.
  2043 
  2207 
  2044     (builder componentAt: #columnView) 
  2208     (builder componentAt: #labelAndColumns) 
  2045         selectConditionBlock: [:i|self checkMenuItemModified];
  2209         selectConditionBlock: [:i|self checkMenuItemModified];
  2046         action: [:i|self cancel];
  2210         action: [:i|self cancel];
  2047         selection: 1
  2211         selection: 1.
  2048 
       
  2049 
  2212 
  2050 
  2213 
  2051 ! !
  2214 ! !
  2052 
  2215 
  2053 !DataSetBuilder methodsFor:'user actions'!
  2216 !DataSetBuilder methodsFor:'user actions'!
  2062 
  2225 
  2063     (column := self selectedColumn) isNil ifTrue: [^self cancel].
  2226     (column := self selectedColumn) isNil ifTrue: [^self cancel].
  2064 
  2227 
  2065     type := (aspects at:#rendererType) value.
  2228     type := (aspects at:#rendererType) value.
  2066 
  2229 
  2067     type == #rowSelector 
  2230     type == #rowSelector ifTrue:[
  2068     ifTrue:
       
  2069     [
       
  2070         #(label width minWidth editorType choices readSelector writeSelector printSelector
  2231         #(label width minWidth editorType choices readSelector writeSelector printSelector
  2071           formatString type size height canSelect selectSelector) do:[:aKey|(aspects at:aKey) value:nil]
  2232           formatString type size height canSelect selectSelector
       
  2233          ) do:[:aKey|
       
  2234             (aspects at:aKey) value:nil
       
  2235         ]
  2072     ].
  2236     ].
  2073         
       
  2074     aspects keysAndValuesDo:[:aKey :aModel| column perform:(aKey , ':') asSymbol with: aModel value].
  2237     aspects keysAndValuesDo:[:aKey :aModel| column perform:(aKey , ':') asSymbol with: aModel value].
  2075     self seqList at:selectedColumnIndex put: (aspects at:#label) value.
  2238     self seqList at:selectedColumnIndex put:(self labelFromColumn:column).
  2076     self updateColumnView.
  2239     self updateColumnView.
  2077     self cancel
  2240     self cancel
  2078 !
  2241 !
  2079 
  2242 
  2080 cancel
  2243 cancel
  2083     self updateInputFields.
  2246     self updateInputFields.
  2084     self valueOfEnablingCommitButtons value:false.
  2247     self valueOfEnablingCommitButtons value:false.
  2085     self columnIsNotEditing value: true.
  2248     self columnIsNotEditing value: true.
  2086 !
  2249 !
  2087 
  2250 
  2088 doBrowseClass
  2251 doBrowseRowClass
  2089     "browse class of columns spec"
  2252     "browse class of columns spec"
  2090 
  2253 
  2091     |cls|
  2254     |cls|
  2092 
  2255 
  2093     (cls := self resolveClassNamed) notNil 
  2256     (cls := self resolveRowClassNamed) notNil 
  2094         ifTrue: [SystemBrowser openInClass:cls] 
  2257         ifTrue: [SystemBrowser openInClass:cls] 
  2095         ifFalse:[self information:'No class defined!!']
  2258         ifFalse:[self information:'No class defined!!']
  2096 
  2259 
  2097 
  2260 
  2098 
  2261 
  2119     label := 'Column ', (list size + 1) printString.
  2282     label := 'Column ', (list size + 1) printString.
  2120     columns add:(DataSetColumnSpec label:label selector:nil) afterIndex:selectedColumnIndex.
  2283     columns add:(DataSetColumnSpec label:label selector:nil) afterIndex:selectedColumnIndex.
  2121     self seqList add:label afterIndex:selectedColumnIndex.
  2284     self seqList add:label afterIndex:selectedColumnIndex.
  2122     hasChanged := true.
  2285     hasChanged := true.
  2123     self valueOfEnablingCommitButtons value ifFalse:[self selectedColumnModel value:selectedColumnIndex + 1].
  2286     self valueOfEnablingCommitButtons value ifFalse:[self selectedColumnModel value:selectedColumnIndex + 1].
  2124     self cancel
  2287     self cancel.
       
  2288     self updateColumnView
  2125 
  2289 
  2126 !
  2290 !
  2127 
  2291 
  2128 doCutColumn
  2292 doCutColumn
  2129     "remove selected column and put it to the clipboard"
  2293     "remove selected column and put it to the clipboard"
  2144         self cancel.
  2308         self cancel.
  2145         hasChanged := true.
  2309         hasChanged := true.
  2146     ]
  2310     ]
  2147 !
  2311 !
  2148 
  2312 
  2149 doDefineClass
  2313 doDefineRowClass
  2150     "launch a dialog to define class and superclass"
  2314     "launch a dialog to define class and superclass"
  2151 
  2315 
  2152     |aspects cls oldClass oldSuper|
  2316     |aspects cls oldClass oldSuper|
  2153 
  2317 
  2154     aspects  := IdentityDictionary new.
  2318     aspects  := IdentityDictionary new.
  2155     oldClass := className.
  2319     oldClass := rowClass.
  2156     oldSuper := superclassName.
  2320     oldSuper := rowSuperClass.
  2157 
  2321 
  2158     [true] 
  2322     [true] 
  2159     whileTrue:
  2323     whileTrue:
  2160     [
  2324     [
  2161         className notNil 
  2325         rowClass notNil 
  2162         ifTrue:
  2326         ifTrue:
  2163         [
  2327         [
  2164             (cls := self resolveClassNamed) notNil 
  2328             (cls := self resolveRowClassNamed) notNil 
  2165             ifTrue:
  2329             ifTrue:
  2166             [
  2330             [
  2167                 superclassName := cls superclass name asString
  2331                 rowSuperClass := cls superclass name asString
  2168             ].
  2332             ].
  2169             aspects at:#classNameChannel put:className asValue
  2333             aspects at:#classNameChannel put:rowClass asValue
  2170         ] 
  2334         ] 
  2171         ifFalse:
  2335         ifFalse:
  2172         [
  2336         [
  2173             aspects at:#classNameChannel put:'DSVRow' asValue
  2337             aspects at:#classNameChannel put:'DSVRow' asValue
  2174         ].
  2338         ].
  2175 
  2339 
  2176         superclassName notNil 
  2340         rowSuperClass notNil 
  2177             ifTrue: [aspects at:#superclassNameChannel put:superclassName asValue] 
  2341             ifTrue: [aspects at:#superclassNameChannel put:rowSuperClass asValue] 
  2178             ifFalse:[aspects at:#superclassNameChannel put:'Object' asValue].
  2342             ifFalse:[aspects at:#superclassNameChannel put:'Object' asValue].
  2179 
  2343 
  2180         (self openDialogInterface:#defineClassNameSpec withBindings:aspects) 
  2344         (self openDialogInterface:#defineClassNameSpec withBindings:aspects) 
  2181         ifFalse:
  2345         ifFalse:
  2182         [
  2346         [
  2183             className := oldClass.
  2347             rowClass := oldClass.
  2184             superclassName := oldSuper.
  2348             rowSuperClass := oldSuper.
  2185             ^self
  2349             ^self
  2186         ].
  2350         ].
  2187         className      := ((aspects at:#classNameChannel) value)      withoutSeparators.
  2351         rowClass      := ((aspects at:#classNameChannel) value)      withoutSeparators.
  2188         superclassName := ((aspects at:#superclassNameChannel) value) withoutSeparators.
  2352         rowSuperClass := ((aspects at:#superclassNameChannel) value) withoutSeparators.
  2189 
  2353 
  2190         className size == 0 
  2354         rowClass size == 0 
  2191         ifTrue:
  2355         ifTrue:
  2192         [
  2356         [
  2193             className := nil.
  2357             rowClass := nil.
  2194             self information:'no valid className'
  2358             self information:'no valid className'
  2195         ] 
  2359         ] 
  2196         ifFalse: 
  2360         ifFalse: 
  2197         [
  2361         [
  2198             cls := self resolveClassNamed.
  2362             cls := self resolveRowClassNamed.
  2199 
  2363 
  2200             cls notNil ifTrue:[cls := cls superclass name asString].
  2364             cls notNil ifTrue:[cls := cls superclass name asString].
  2201 
  2365 
  2202             superclassName size == 0 
  2366             rowSuperClass size == 0 
  2203             ifTrue:
  2367             ifTrue:
  2204             [        
  2368             [        
  2205                 cls notNil ifTrue:[
  2369                 cls notNil ifTrue:[
  2206                     superclassName := cls
  2370                     rowSuperClass := cls
  2207                 ] ifFalse:[
  2371                 ] ifFalse:[
  2208                     superclassName := 'Object'
  2372                     rowSuperClass := 'Object'
  2209                 ].
  2373                 ].
  2210                 self information: 'set superclassName'
  2374                 self information: 'set superclassName'
  2211             ] 
  2375             ] 
  2212             ifFalse:
  2376             ifFalse:
  2213             [
  2377             [
  2214                 (cls isNil or:[superclassName = cls]) ifTrue:[hasChanged := true. ^self].
  2378                 (cls isNil or:[rowSuperClass = cls]) ifTrue:[hasChanged := true. ^self].
  2215                 self information:('A global named ' , className , ' exists,\' ,
  2379                 self information:('A global named ' , rowClass , ' exists,\' ,
  2216                                   'but is not a subclass of ' , superclassName, '.\\' ,
  2380                                   'but is not a subclass of ' , rowSuperClass, '.\\' ,
  2217                                   'Check and try again if that is not what you want.') withCRs.
  2381                                   'Check and try again if that is not what you want.') withCRs.
  2218 
  2382 
  2219                 superclassName := cls
  2383                 rowSuperClass := cls
  2220             ]
  2384             ]
  2221         ]
  2385         ]
  2222     ]
  2386     ]
  2223 !
  2387 !
  2224 
  2388 
  2225 doGenerateCode
  2389 doGenerateCode
  2226     "generate code for column values"
  2390     "generate code for column values"
  2227 
  2391 
  2228     |cls superclass|
  2392     |cls superclass|
  2229 
  2393 
  2230     className isNil ifTrue:[^self information:'No class defined!!'].
  2394     rowClass isNil ifTrue:[^self information:'No class defined!!'].
  2231     cls := self resolveClassNamed.
  2395     cls := self resolveRowClassNamed.
  2232 
  2396 
  2233     cls isNil 
  2397     cls isNil 
  2234     ifTrue:
  2398     ifTrue:
  2235     [
  2399     [
  2236         superclass := Smalltalk resolveName:superclassName inClass:self class.
  2400         superclass := Smalltalk resolveName:rowSuperClass inClass:self class.
  2237 
  2401 
  2238         superclass isNil ifTrue:[^self information:'No superclass defined!!'].
  2402         superclass isNil ifTrue:[^self information:'No superclass defined!!'].
  2239         (self confirm:'create ' , className , ' ?') ifFalse:[^self].
  2403         (self confirm:'create ' , rowClass , ' ?') ifFalse:[^self].
  2240         cls := superclass subclass:className asSymbol
  2404         cls := superclass subclass:rowClass asSymbol
  2241                      instanceVariableNames:''
  2405                      instanceVariableNames:''
  2242                      classVariableNames:''
  2406                      classVariableNames:''
  2243                      poolDictionaries:''
  2407                      poolDictionaries:''
  2244                      category:'Applications'.
  2408                      category:'Applications'.
  2245     ].
  2409     ].
  2290 !
  2454 !
  2291 
  2455 
  2292 doPasteColumn
  2456 doPasteColumn
  2293     "paste clipboard copy column after selected column or at left (nothing selected)"
  2457     "paste clipboard copy column after selected column or at left (nothing selected)"
  2294 
  2458 
  2295     |label list|
  2459     |col lbl|
  2296 
  2460 
  2297     self checkMenuItemModified ifFalse: [^nil].
  2461     self checkMenuItemModified ifFalse: [^nil].
  2298     list := self seqList.
  2462     col := self class clipboard deepCopy.
  2299     label := self class clipboard label.
  2463     lbl := self labelFromColumn:col.
  2300     columns add: self class clipboard deepCopy afterIndex:selectedColumnIndex.
  2464 
  2301     self seqList add: label afterIndex:selectedColumnIndex.
  2465     columns add:col afterIndex:selectedColumnIndex.
       
  2466     self seqList add:lbl afterIndex:selectedColumnIndex.
  2302     hasChanged := true.
  2467     hasChanged := true.
  2303 
  2468 
  2304     self valueOfEnablingCommitButtons value ifFalse:[self selectedColumnModel value:selectedColumnIndex + 1].
  2469     self valueOfEnablingCommitButtons value ifFalse:[
       
  2470         self selectedColumnModel value:selectedColumnIndex + 1
       
  2471     ].
  2305     self updateColumnView.
  2472     self updateColumnView.
  2306     self updateInputFields.
  2473     self updateInputFields.
       
  2474 !
       
  2475 
       
  2476 doPickColumns
       
  2477 
       
  2478     |view cls|
       
  2479 
       
  2480     view := Screen current viewFromUser.
       
  2481     cls  := view class.
       
  2482 
       
  2483     (cls == DSVColumnView or:[cls == DataSetView or:[cls == DSVLabelView]]) ifTrue:[
       
  2484         self columns:(view columnView columnDescriptors)
       
  2485     ]
       
  2486 !
       
  2487 
       
  2488 doSave
       
  2489     |cls dst spc idx category mthd excla code resourceType|
       
  2490 
       
  2491     (columns size ~~ 0 and:[super doSave]) ifFalse:[
       
  2492         ^ nil
       
  2493     ].
       
  2494     cls := self resolveName:specClass.
       
  2495     dst := columns collect:[:aCol| aCol literalArrayEncoding ].
       
  2496     spc := WriteStream on:String new.
       
  2497     UISpecification prettyPrintSpecArray:dst asArray on:spc indent:4.
       
  2498     spc := spc contents.
       
  2499     idx := (spc indexOfNonSeparatorStartingAt:1) - 2.
       
  2500 
       
  2501     spc at:idx put:$^.
       
  2502 
       
  2503     "/ if that method already exists, do not overwrite the category
       
  2504 
       
  2505     resourceType := self class resourceType.
       
  2506     category     := resourceType, ' specs'.
       
  2507 
       
  2508     (mthd := cls class compiledMethodAt:specSelector) notNil ifTrue:[
       
  2509         category := mthd category.
       
  2510     ].
       
  2511 
       
  2512     excla := Character excla asString.
       
  2513 
       
  2514     code := excla
       
  2515             , (cls name , ' class methodsFor:' , category storeString)
       
  2516             , excla , '\\'
       
  2517 
       
  2518             , specSelector , '\'
       
  2519             , (self class codeGenerationComment replChar:$!! withString:'!!!!')
       
  2520             , '\\    "\'
       
  2521             , ('     DataSetBuilder new openOnClass:' , cls name , ' andSelector:#' , specSelector , '\')
       
  2522             , '    "\'.
       
  2523 
       
  2524     code := code 
       
  2525             , '\'
       
  2526             , '    <resource: #', resourceType, '>\\'
       
  2527             , spc
       
  2528             , '\'
       
  2529             , (excla , ' ' , excla)
       
  2530             , '\\'.
       
  2531 
       
  2532     code := code withCRs.
       
  2533     (ReadStream on:code) fileIn.
       
  2534 
       
  2535 "/    self isStandAlone ifTrue: [self helpTool installHelpSpecsOnClass:self specClass].
       
  2536 
       
  2537     self updateHistory.
       
  2538     self updateInfoLabel.
       
  2539 
       
  2540     hasSaved := true.
       
  2541     modified := false.
       
  2542 
  2307 ! !
  2543 ! !
  2308 
  2544 
  2309 !DataSetBuilder class methodsFor:'documentation'!
  2545 !DataSetBuilder class methodsFor:'documentation'!
  2310 
  2546 
  2311 version
  2547 version