813 " |
813 " |
814 |
814 |
815 ^ super helpSpec addPairsFrom:#( |
815 ^ super helpSpec addPairsFrom:#( |
816 |
816 |
817 #backgroundColor |
817 #backgroundColor |
818 'set the background color of the column if the color-checkBox is turned on. Otherwise, the column uses its default background color (which is specified in the styleSheet).' |
818 'Sets the background color of the column if the color-checkBox is turned on. Otherwise, the column uses its default background color (which is specified in the styleSheet).' |
819 |
819 |
820 #backgroundSelector |
820 #backgroundSelector |
821 'selector which returns the background color for a cell (optional). If the selector is nil or returns nil, the default background color is set.' |
821 'Selector which returns the background color for a cell (optional). If the selector is nil or returns nil, the default background color is set.' |
822 |
822 |
823 #canSelect |
823 #canSelect |
824 'if true, each cell in the column can be selected. In case of having a menu, the menu can be opened by selecting the cell and pressing down the right or middle button of the mouse. if false, the whole line is selected. The menu opened derives from the DataSetView, which is specified in the window specification (Basics).' |
824 'If true, each cell in the column can be selected. In case of having a menu, the menu can be opened by selecting the cell and pressing down the right or middle button of the mouse. if false, the whole line is selected. The menu opened derives from the DataSetView, which is specified in the window specification (Basics).' |
825 |
825 |
826 #choices |
826 #choices |
827 'selector to get the collection of choices for a column which is selectable and its editor is kind of a ComboBox or ComboList. If a cell in the column is selected, the visual editor is opened and in case of having choices, the choices are assigned to the widget.' |
827 'Selector to get the collection of choices for a column which is selectable and its editor is kind of a ComboBox or ComboList. If a cell in the column is selected, the visual editor is opened and in case of having choices, the choices are assigned to the widget.' |
|
828 |
|
829 #doubleClickedSelector |
|
830 'Selector evaluated without arguments on selected column.' |
828 |
831 |
829 #editorField |
832 #editorField |
830 'type of visual editor (using default editors) or a selector, which will return an visual editor. If the cell is selected, a visual editor is opened in in the cell. In case of an unsupported selector (user defined editor), the row object is asked for the visual editor by performing the selector on the row. A widget instance must be returned which is opened in the cell.' |
833 'Type of visual editor (using default editors) or a selector, which will return an visual editor. If the cell is selected, a visual editor is opened in in the cell. In case of an unsupported selector (user defined editor), the row object is asked for the visual editor by performing the selector on the row. A widget instance must be returned which is opened in the cell.' |
831 |
|
832 #doubleClickedSelector |
|
833 'selector evaluated without arguments on selected column' |
|
834 |
834 |
835 #foregroundColor |
835 #foregroundColor |
836 'set the foreground color of the column if the color-checkBox is turned on. Otherwise, the column uses its default foreground color (which is specified in the styleSheet).' |
836 'Sets the foreground color of the column if the color-checkBox is turned on. Otherwise, the column uses its default foreground color (which is specified in the styleSheet).' |
837 |
837 |
838 #foregroundSelector |
838 #foregroundSelector |
839 'selector which returns the foreground color for a cell (optional). If the selector is nil or returns nil, the default foreground color is set.' |
839 'Selector which returns the foreground color for a cell (optional). If the selector is nil or returns nil, the default foreground color is set.' |
840 |
840 |
841 #formatString |
841 #formatString |
842 'format string, which specifies the output format of a text in a cell. \ At the moment only numbers are supported. \ \ for example: 0.0000' |
842 'Format string, which specifies the output format of a text in a cell. At the moment only numbers are supported (for example: 0.0000).' |
843 |
843 |
844 #height |
844 #height |
845 'preferred height (optional)' |
845 'Preferred height (optional).' |
846 |
846 |
847 #label |
847 #label |
848 'the label of the column. If ''label is image'' is off, this is the label string. Otherwise, it specifies the applications selector, which returns the label - either a string or a bitmap image.' |
848 'The label of the column. If ''label is image'' is off, this is the label string. Otherwise, it specifies the applications selector, which returns the label - either a string or a bitmap image.' |
849 |
849 |
850 #labelIsImage |
850 #labelIsImage |
851 'if ''label is image'' is off (the default), the columns label is the string as entered in the label aspect. Otherwise, its the name of the message sent to the application - this should return a string or bitmap image, which is used as logo in the column.' |
851 'If ''label is image'' is off (the default), the columns label is the string as entered in the label aspect. Otherwise, its the name of the message sent to the application - this should return a string or bitmap image, which is used as logo in the column.' |
852 |
852 |
853 #menuSelector |
853 #menuSelector |
854 'a selector to access the middleButton menu or nil. If a cell is selected. The menu will be opened by selecting the cell and pressing down the right or middle button of the mouse.' |
854 'A selector to access the middleButton menu or nil. If a cell is selected. The menu will be opened by selecting the cell and pressing down the right or middle button of the mouse.' |
855 |
855 |
856 #minWidth |
856 #minWidth |
857 'makes sense if the width is set to 0 or nil. This is the minimum size required; no computation dependent on the contents. When resizing the view the column may grow or shrink to the minimum width.' |
857 'Makes sense if the width is set to 0 or nil. This is the minimum size required; no computation dependent on the contents. When resizing the view the column may grow or shrink to the minimum width.' |
858 |
858 |
859 #printSelector |
859 #printSelector |
860 'a selector with one argument, the DataSetView. Used to access a drawable display object. In case of nil, the value derived from the readSelector is shown in the unselected cell.\ \ Using bitmaps, the DataSetView offers three important methods:\ \ #registerImage:anImage key:aSymbol\ register an image with an unique symbol. This symbol can be used by the row object to access the image, using #registeredImageAt:. The image will be associated to the device.\ \ #registeredImageAt:aSymbol\ returns an image assigned to the symbol or nil. The image returned is associated to the device.\ \ #releaseAllRegisteredImages\ relaese all registered images' |
860 'A selector with one argument, the DataSetView. Used to access a drawable display object. In case of nil, the value derived from the readSelector is shown in the unselected cell.\ \ Using bitmaps, the DataSetView offers three important methods:\ \ #registerImage:anImage key:aSymbol\ register an image with an unique symbol. This symbol can be used by the row object to access the image, using #registeredImageAt:. The image will be associated to the device.\ \ #registeredImageAt:aSymbol\ returns an image assigned to the symbol or nil. The image returned is associated to the device.\ \ #releaseAllRegisteredImages\ relaese all registered images.' |
861 |
861 |
862 #readSelector |
862 #readSelector |
863 'a selector, which is used to get or set (if the write selector is undefined) the value of a cell. The value returned by the method can be a string object or a bitmap. The set operation only is performed if the column is selectable.' |
863 'A selector, which is used to get or set (if the write selector is undefined) the value of a cell. The value returned by the method can be a string object or a bitmap. The set operation only is performed if the column is selectable.' |
864 |
864 |
865 #rendererType |
865 #rendererType |
866 'This type specifies, how the text of an unselected cell should be shown. As Text, CheckToggle, ComboBox, ComboList or as a RowSelector.' |
866 'This type specifies, how the text of an unselected cell should be shown. As Text, CheckToggle, ComboBox, ComboList or as a RowSelector.' |
867 |
867 |
868 #selectSelector |
868 #selectSelector |
869 'an optional selector, which is used to test whether the cell in the column is selectable; the ''Is Selectable'' flag must be enabled.' |
869 'An optional selector, which is used to test whether the cell in the column is selectable; the ''Is Selectable'' flag must be enabled.' |
870 |
870 |
871 #showColumnSeparator |
871 #showColumnSeparator |
872 'show or hide the column separator (right vertical separator).' |
872 'Shows or hide the column separator (right vertical separator).' |
873 |
873 |
874 #showRowSeparator |
874 #showRowSeparator |
875 'show or hide the row separator (bottom horizontal separator)' |
875 'Shows or hide the row separator (bottom horizontal separator).' |
876 |
876 |
877 #size |
877 #size |
878 'max size of an InputField, ComboBox or ComboList. 0 or nil means unlimited.' |
878 'Max size of an InputField, ComboBox or ComboList. 0 or nil means unlimited.' |
879 |
879 |
880 #type |
880 #type |
881 'a type converter symbol used by the input field' |
881 'A type converter symbol used by the input field.' |
882 |
882 |
883 #width |
883 #width |
884 'the width of a fixed column; in case of nil or 0 the column width will be computed dependent on the contents.' |
884 'The width of a fixed column; in case of nil or 0 the column width will be computed dependent on the contents.' |
885 |
885 |
886 #writeSelector |
886 #writeSelector |
887 'a selector, which is used to set the value of a cell. If the selector is not defined, the selector derives from the printSelector.' |
887 'A selector, which is used to set the value of a cell. If the selector is not defined, the selector derives from the printSelector.' |
888 |
888 |
889 ) |
889 ) |
890 ! ! |
890 ! ! |
891 |
891 |
892 !DataSetBuilder class methodsFor:'interface specs'! |
892 !DataSetBuilder class methodsFor:'interface specs'! |
1319 |
1321 |
1320 newColumnIcon |
1322 newColumnIcon |
1321 "ImageEditor openOnClass:self andSelector:#newColumnIcon" |
1323 "ImageEditor openOnClass:self andSelector:#newColumnIcon" |
1322 |
1324 |
1323 <resource: #image> |
1325 <resource: #image> |
1324 ^(Depth4Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(#[17 17 16 0 0 0 0 0 0 17 17 17 17 16 17 17 17 17 17 32 17 17 17 17 16 18 34 34 34 34 48 17 17 17 17 16 18 32 2 32 34 48 17 17 17 17 16 18 2 34 2 2 48 17 17 17 17 16 18 2 34 2 2 48 17 17 17 17 16 18 32 2 32 34 48 17 17 16 17 16 18 34 34 34 34 48 17 17 17 17 16 18 2 34 2 2 48 17 17 17 17 16 18 2 34 2 2 48 17 17 17 17 16 18 2 34 2 2 48 17 17 17 17 16 18 0 2 0 2 48 17 17 17 17 16 18 34 34 34 34 48 17 17 17 17 16 18 34 34 34 34 48 17 17 17 17 16 18 2 2 2 2 48 17 17 17 17 16 18 0 2 0 2 48 17 17 17 17 16 18 2 2 0 2 48 17 17 17 17 16 18 2 2 2 2 48 17 17 17 17 16 18 34 34 34 34 48 17 17 17 17 16 18 34 34 34 34 48 17 17 17 17 16 35 51 51 51 51 48 17 17 17 17 16 0 0 0 0 0 0 17 17]) ; colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color grey:66.9978); add:(Color grey:49.9962); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9992 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9992 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9992); add:(Color red:0.0 green:49.9992 blue:49.9992); add:(Color red:49.9992 green:49.9992 blue:0.0); add:(Color red:49.9992 green:0.0 blue:49.9992); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 195 7 255 192 7 255 192 7 255 192 7 255 192 7 255 195 7 255 193 7 255 192 7 255 195 7 255 192 7 255 195 7 255 192 7 255 192 7 255 193]) ; yourself); yourself! ! |
1326 ^(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[85 64 0 0 5 80 85 69 85 85 133 80 85 70 170 170 197 80 85 70 130 138 197 80 85 70 42 34 197 89 85 70 42 34 197 80 85 70 130 138 197 80 69 70 170 170 197 80 85 70 42 34 197 80 85 70 42 34 197 80 85 70 42 34 197 80 85 70 2 2 197 80 85 70 170 170 197 80 85 70 170 170 197 80 85 70 34 34 197 89 85 70 2 2 197 80 85 70 34 2 197 80 85 70 34 34 197 80 85 70 170 170 197 80 85 70 170 170 197 80 85 75 255 255 197 80 85 64 0 0 5 80]) ; colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:66.9978)); at:4 put:((Color grey:49.9962)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(#[7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 192 7 255 195 7 255 192 7 255 192 7 255 192 7 255 192 7 255 195 7 255 193 7 255 192 7 255 195 7 255 192 7 255 195 7 255 192 7 255 192 7 255 193]) ; yourself); yourself! ! |
1325 |
1327 |
1326 !DataSetBuilder methodsFor:'accessing'! |
1328 !DataSetBuilder methodsFor:'accessing'! |
1327 |
1329 |
1328 columns |
1330 columns |
1329 "returns list of columns |
1331 "returns list of columns" |
1330 " |
1332 |
1331 ^ columns |
1333 ^columns |
1332 ! |
1334 ! |
1333 |
1335 |
1334 columns:aListOfColumns fromView:aColumnView |
1336 columns:aListOfColumns fromView:aColumnView |
1335 "setup columns from a column view |
1337 "setup columns from a column view" |
1336 " |
1338 |
1337 |list| |
1339 |list| |
1338 |
1340 |
1339 columnView := aColumnView. |
1341 columnView := aColumnView. |
1340 columns := OrderedCollection new. |
1342 columns := OrderedCollection new. |
1341 list := self seqList. |
1343 list := self seqList. |
1342 hasChanged := false. |
1344 hasChanged := false. |
1343 |
1345 |
1344 list removeAll. |
1346 list removeAll. |
1345 |
1347 |
1346 aListOfColumns size ~~ 0 ifTrue:[ |
1348 aListOfColumns size ~~ 0 |
1347 aListOfColumns do:[:aCol| |
1349 ifTrue: |
1348 columns add:(aCol copy). |
1350 [ |
1349 aCol rendererType == #rowSelector ifFalse:[list add:(aCol label)] |
1351 aListOfColumns do: |
1350 ifTrue:[list add:'Row Selector']. |
1352 [:aColumn| |
1351 ] |
1353 columns add: aColumn copy. |
1352 ]. |
1354 aColumn rendererType == #rowSelector |
1353 ! |
1355 ifFalse:[list add: aColumn label] |
1354 |
1356 ifTrue: [list add:'Row Selector'] |
1355 rowClassName |
|
1356 ^ (Smalltalk resolveName:className inClass:self class) notNil ifTrue:[className] ifFalse:[nil] |
|
1357 ! |
|
1358 |
|
1359 rowClassName:aClassName |
|
1360 |cls| |
|
1361 |
|
1362 superclassName := nil. |
|
1363 |
|
1364 (className := aClassName) notNil ifTrue:[ |
|
1365 (cls := self resolveClassNamed) notNil ifTrue:[ |
|
1366 superclassName := cls superclass name asString. |
|
1367 ] ifFalse:[ |
|
1368 superclassName := 'Object' |
|
1369 ] |
1357 ] |
1370 ] |
1358 ] |
|
1359 ! |
|
1360 |
|
1361 rowClassName |
|
1362 |
|
1363 ^(Smalltalk resolveName:className inClass:self class) notNil ifTrue:[className] ifFalse:[nil] |
|
1364 ! |
|
1365 |
|
1366 rowClassName:aClassName |
|
1367 |
|
1368 |cls| |
|
1369 |
|
1370 superclassName := nil. |
|
1371 |
|
1372 (className := aClassName) notNil |
|
1373 ifTrue: |
|
1374 [ |
|
1375 (cls := self resolveClassNamed) notNil |
|
1376 ifTrue: [superclassName := cls superclass name asString] |
|
1377 ifFalse:[superclassName := 'Object'] |
|
1378 ] |
1371 |
1379 |
1372 ! ! |
1380 ! ! |
1373 |
1381 |
1374 !DataSetBuilder methodsFor:'accessing menu'! |
1382 !DataSetBuilder methodsFor:'aspects'! |
1375 |
1383 |
1376 columnMenu |
1384 aspectFor:aKey |
1377 "this window spec was automatically generated by the UI Builder" |
1385 "returns aspect for a key or nil" |
1378 |
1386 |
1379 ^ self class columnMenu |
1387 ^aspects at:aKey ifAbsent:[super aspectFor:aKey] |
1380 |
1388 |
1381 |
1389 |
1382 ! |
1390 ! |
1383 |
1391 |
1384 doBrowseClass |
1392 columnIsNotEditing |
1385 |cls| |
1393 "returns a boolean value holder which is set to true if column is not editing" |
1386 |
1394 |
1387 (cls := self resolveClassNamed) notNil ifTrue:[ |
1395 ^builder valueAspectFor:#columnIsNotEditing initialValue: true |
1388 SystemBrowser openInClass:cls |
1396 |
1389 ] ifFalse:[ |
1397 |
1390 self information:'No class defined!!' |
1398 |
1391 ] |
1399 ! |
1392 |
1400 |
1393 |
1401 editorTypeList |
1394 |
1402 "generate list of supported editor types" |
1395 ! |
1403 |
1396 |
1404 |list| |
1397 doCopyColumn |
1405 |
1398 "copy selected column to the clipboard" |
1406 (list := builder bindingAt:#editorTypeList) isNil |
1399 |
1407 ifTrue: |
1400 |idx| |
1408 [ |
1401 |
1409 list := OrderedCollection new. |
1402 (idx := selectedColumnIndex) ~~ 0 ifTrue:[ |
1410 DataSetColumnSpec slices do: |
1403 self clipboard: (columns at: idx) deepCopy. |
1411 [:aSlice||type| |
|
1412 type := aSlice at:1. |
|
1413 (list includes:type) ifFalse:[list add:type] |
|
1414 ]. |
|
1415 builder aspectAt:#editorTypeList put:list |
1404 ]. |
1416 ]. |
1405 ! |
1417 ^list |
1406 |
|
1407 doCreateColumn |
|
1408 "create a new column after selected column or at left (nothing selected) |
|
1409 " |
|
1410 |label list| |
|
1411 |
|
1412 list := self seqList. |
|
1413 label := 'Column ', list size printString. |
|
1414 columns add:(DataSetColumnSpec label:label selector:nil) afterIndex:selectedColumnIndex. |
|
1415 self seqList add:label afterIndex:selectedColumnIndex. |
|
1416 hasChanged := true. |
|
1417 |
|
1418 self modified ifFalse:[ |
|
1419 self selectedColumnModel value:(selectedColumnIndex + 1) |
|
1420 ]. |
|
1421 self updateColumnView. |
|
1422 |
|
1423 ! |
|
1424 |
|
1425 doCutColumn |
|
1426 "remove selected column and put it to the clipboard" |
|
1427 |
|
1428 |idx| |
|
1429 |
|
1430 (idx := selectedColumnIndex) ~~ 0 ifTrue:[ |
|
1431 self selectedColumnModel value:0. |
|
1432 self clipboard: (columns at: idx). |
|
1433 columns removeIndex:idx. |
|
1434 self seqList removeIndex:idx. |
|
1435 self updateColumnView. |
|
1436 columns isEmpty ifTrue: [self isColumnSelected value: false]. |
|
1437 hasChanged := true |
|
1438 ]. |
|
1439 ! |
|
1440 |
|
1441 doDefineClass |
|
1442 "launch a dialog to define class and superclass |
|
1443 " |
|
1444 |aspects cls oldClass oldSuper| |
|
1445 |
|
1446 aspects := IdentityDictionary new. |
|
1447 oldClass := className. |
|
1448 oldSuper := superclassName. |
|
1449 |
|
1450 [true] whileTrue:[ |
|
1451 className notNil ifTrue:[ |
|
1452 (cls := self resolveClassNamed) notNil ifTrue:[ |
|
1453 superclassName := cls superclass name asString. |
|
1454 ]. |
|
1455 aspects at:#classNameChannel put:className asValue |
|
1456 ] ifFalse:[ |
|
1457 aspects at:#classNameChannel put:'DSVRow' asValue |
|
1458 ]. |
|
1459 |
|
1460 superclassName notNil ifTrue:[ |
|
1461 aspects at:#superclassNameChannel put:superclassName asValue |
|
1462 ] ifFalse:[ |
|
1463 aspects at:#superclassNameChannel put:'Object' asValue |
|
1464 ]. |
|
1465 |
|
1466 (self openDialogInterface:#defineClassNameSpec withBindings:aspects) ifFalse:[ |
|
1467 className := oldClass. |
|
1468 superclassName := oldSuper. |
|
1469 ^ self |
|
1470 ]. |
|
1471 className := ((aspects at:#classNameChannel) value) withoutSeparators. |
|
1472 superclassName := ((aspects at:#superclassNameChannel) value) withoutSeparators. |
|
1473 |
|
1474 className size == 0 ifTrue:[ |
|
1475 className := nil. |
|
1476 self information:'no valid className'. |
|
1477 ] ifFalse:[ |
|
1478 cls := self resolveClassNamed. |
|
1479 |
|
1480 cls notNil ifTrue:[ |
|
1481 cls := cls superclass name asString |
|
1482 ]. |
|
1483 |
|
1484 superclassName size == 0 ifTrue:[ |
|
1485 cls notNil ifTrue:[ |
|
1486 superclassName := cls |
|
1487 ] ifFalse:[ |
|
1488 superclassName := 'Object' |
|
1489 ]. |
|
1490 self information:( 'set superclassName' ). |
|
1491 ] ifFalse:[ |
|
1492 (cls isNil or:[superclassName = cls]) ifTrue:[ |
|
1493 hasChanged := true. |
|
1494 ^ self |
|
1495 ]. |
|
1496 self information:('a global named ' , className , ' exists,\' , |
|
1497 'but is not a subclass of ' , superclassName, '.\\' , |
|
1498 'Check and try again if that is not what you want.') withCRs. |
|
1499 |
|
1500 superclassName := cls. |
|
1501 ] |
|
1502 ] |
|
1503 ] |
|
1504 ! |
|
1505 |
|
1506 doGenerateCode |
|
1507 |cls superclass| |
|
1508 |
|
1509 className isNil ifTrue:[ |
|
1510 ^ self information:'No class defined!!' |
|
1511 ]. |
|
1512 cls := self resolveClassNamed. |
|
1513 |
|
1514 cls isNil ifTrue:[ |
|
1515 superclass := Smalltalk resolveName:superclassName inClass:self class. |
|
1516 |
|
1517 superclass isNil ifTrue:[ |
|
1518 ^ self information:'no superclass defined' |
|
1519 ]. |
|
1520 (self confirm:'create ' , className , ' ?') ifFalse:[ |
|
1521 ^ self |
|
1522 ]. |
|
1523 cls := superclass subclass:(className asSymbol) |
|
1524 instanceVariableNames:'' |
|
1525 classVariableNames:'' |
|
1526 poolDictionaries:'' |
|
1527 category:'Applications'. |
|
1528 ]. |
|
1529 |
|
1530 self generateChoicesIn:cls. |
|
1531 self generateMenuIn:cls. |
|
1532 self generatePrintSelectorIn:cls. |
|
1533 self generateReadSelectorIn:cls. |
|
1534 self generateBackgroundSelectorIn:cls. |
|
1535 self generateForegroundSelectorIn:cls. |
|
1536 self generateSelectSelectorIn:cls. |
|
1537 self generateWriteSelectorIn:cls. |
|
1538 self generateDoubleClickSelectorIn:cls. |
|
1539 ! |
|
1540 |
|
1541 doMoveColumn:upOrDown |
|
1542 "move selected column up or down |
|
1543 " |
|
1544 |idx list label col size| |
|
1545 |
|
1546 (idx := selectedColumnIndex) == 0 ifTrue:[ |
|
1547 ^ self |
|
1548 ]. |
|
1549 list := self seqList. |
|
1550 size := list size. |
|
1551 |
|
1552 size == 1 ifTrue:[ |
|
1553 ^ self |
|
1554 ]. |
|
1555 hasChanged := true. |
|
1556 selectedColumnIndex := 0. |
|
1557 label := list at:idx. |
|
1558 col := columns at:idx. |
|
1559 list removeIndex:idx. |
|
1560 columns removeIndex:idx. |
|
1561 |
|
1562 upOrDown == #up ifTrue:[ |
|
1563 idx == 1 ifTrue:[idx := size] |
|
1564 ifFalse:[idx := idx - 1] |
|
1565 ] ifFalse:[ |
|
1566 idx == size ifTrue:[idx := 1] |
|
1567 ifFalse:[idx := idx + 1] |
|
1568 ]. |
|
1569 columns add:col beforeIndex:idx. |
|
1570 list add:label beforeIndex:idx. |
|
1571 self selectedColumnModel value:idx. |
|
1572 self updateColumnView. |
|
1573 ! |
|
1574 |
|
1575 doPasteColumn |
|
1576 "paste clipboard copy column after selected column or at left (nothing selected) |
|
1577 " |
|
1578 |label list| |
|
1579 |
|
1580 list := self seqList. |
|
1581 label := self class clipboard label. |
|
1582 columns add: self class clipboard deepCopy afterIndex:selectedColumnIndex. |
|
1583 self seqList add: label afterIndex:selectedColumnIndex. |
|
1584 hasChanged := true. |
|
1585 |
|
1586 self modified ifFalse:[ |
|
1587 self selectedColumnModel value:(selectedColumnIndex + 1) |
|
1588 ]. |
|
1589 self updateColumnView. |
|
1590 |
|
1591 ! |
|
1592 |
|
1593 mainMenu |
|
1594 "this window spec was automatically generated by the UI Builder" |
|
1595 |
|
1596 ^ self class mainMenu |
|
1597 |
|
1598 |
|
1599 ! |
|
1600 |
|
1601 menu |
|
1602 "this window spec was automatically generated by the UI Builder" |
|
1603 |
|
1604 ^ self class menu |
|
1605 |
|
1606 |
|
1607 ! |
|
1608 |
|
1609 menuEdit |
|
1610 "this window spec was automatically generated by the UI Builder" |
|
1611 |
|
1612 ^ self class menuEdit |
|
1613 |
|
1614 |
|
1615 ! |
|
1616 |
|
1617 menuToolbar |
|
1618 "this window spec was automatically generated by the UI Builder" |
|
1619 |
|
1620 ^ self class menuToolbar |
|
1621 |
|
1622 |
|
1623 ! |
|
1624 |
|
1625 subMenu |
|
1626 "this window spec was automatically generated by the UI Builder" |
|
1627 |
|
1628 ^ self class subMenu |
|
1629 |
|
1630 |
|
1631 ! ! |
|
1632 |
|
1633 !DataSetBuilder methodsFor:'actions'! |
|
1634 |
|
1635 accept |
|
1636 "accept changes made |
|
1637 " |
|
1638 |column type| |
|
1639 |
|
1640 self modifiedChannel value == false ifTrue:[ |
|
1641 ^ self |
|
1642 ]. |
|
1643 isModified := true. |
|
1644 |
|
1645 (column := self selectedColumn) isNil ifTrue:[ |
|
1646 ^ self cancel |
|
1647 ]. |
|
1648 |
|
1649 type := (aspects at:#rendererType) value. |
|
1650 |
|
1651 type == #rowSelector ifTrue:[ |
|
1652 #( label width minWidth editorType choices readSelector writeSelector printSelector |
|
1653 formatString type size height canSelect selectSelector |
|
1654 ) do:[:aKey| (aspects at:aKey) value:nil ]. |
|
1655 ]. |
|
1656 |
|
1657 aspects keysAndValuesDo:[:aKey :aModel| |
|
1658 column perform:(aKey , ':') asSymbol with:(aModel value). |
|
1659 ]. |
|
1660 self seqList at:selectedColumnIndex put:((aspects at:#label) value). |
|
1661 self updateColumnView. |
|
1662 self cancel |
|
1663 ! |
|
1664 |
|
1665 cancel |
|
1666 "remove all changes and reload selected column |
|
1667 " |
|
1668 |column| |
|
1669 |
|
1670 isModified := true. |
|
1671 (column := self selectedColumn) isNil ifTrue:[ |
|
1672 self tabModel value:0. |
|
1673 ] ifFalse:[ |
|
1674 aspects keysAndValuesDo:[:aKey :aModel| |
|
1675 aModel value:(column perform:aKey) |
|
1676 ]. |
|
1677 tabSelectionIndex == 0 ifTrue:[self tabModel value:1]. |
|
1678 ]. |
|
1679 self modifiedChannel value:false. |
|
1680 isModified := false. |
|
1681 ! ! |
|
1682 |
|
1683 !DataSetBuilder methodsFor:'aspects'! |
|
1684 |
|
1685 aspectFor:aKey |
|
1686 "returns aspect for a key or nil |
|
1687 " |
|
1688 ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ] |
|
1689 |
|
1690 |
|
1691 ! |
|
1692 |
|
1693 editorTypeList |
|
1694 "generate list of supported editor types |
|
1695 " |
|
1696 |list| |
|
1697 |
|
1698 (list := builder bindingAt:#editorTypeList) isNil ifTrue:[ |
|
1699 list := OrderedCollection new. |
|
1700 DataSetColumnSpec slices do:[:aSlice||type| |
|
1701 type := aSlice at:1. |
|
1702 (list includes:type) ifFalse:[list add:type]. |
|
1703 ]. |
|
1704 builder aspectAt:#editorTypeList put:list. |
|
1705 |
|
1706 ]. |
|
1707 ^ list |
|
1708 ! |
1418 ! |
1709 |
1419 |
1710 isColumnSelected |
1420 isColumnSelected |
1711 "returns a boolean value holder which is set to true if something is modified |
1421 "returns a boolean value holder which is set to true if something is modified |
1712 and not accepted |
1422 and not accepted" |
1713 " |
1423 |
1714 ^ builder valueAspectFor:#isColumnSelected initialValue: false |
1424 ^builder valueAspectFor:#isColumnSelected initialValue: false |
1715 |
1425 |
1716 |
1426 |
1717 |
1427 |
1718 ! |
1428 ! |
1719 |
1429 |
1720 modifiedChannel |
1430 modifiedChannel |
1721 "returns a boolean value holder which is set to true if something is modified |
1431 "returns a boolean value holder which is set to true if something is modified |
1722 and not accepted |
1432 and not accepted" |
1723 " |
1433 |
1724 ^ builder booleanValueAspectFor:#modifiedChannel |
1434 ^builder booleanValueAspectFor:#modifiedChannel |
1725 |
1435 |
1726 |
1436 |
1727 |
1437 |
1728 ! |
1438 ! |
1729 |
1439 |
1730 rendererTypeList |
1440 rendererTypeList |
1731 "generate list of supported renderer types |
1441 "generate list of supported renderer types" |
1732 " |
1442 |
1733 |list| |
1443 |list| |
1734 |
1444 |
1735 (list := builder bindingAt:#rendererTypeList) isNil ifTrue:[ |
1445 (list := builder bindingAt:#rendererTypeList) isNil |
|
1446 ifTrue: |
|
1447 [ |
1736 list := OrderedCollection new. |
1448 list := OrderedCollection new. |
1737 DataSetColumnSpec slices do:[:aSlice||type| |
1449 DataSetColumnSpec slices do: |
|
1450 [:aSlice||type| |
1738 type := aSlice at:2. |
1451 type := aSlice at:2. |
1739 (list includes:type) ifFalse:[list add:type]. |
1452 (list includes:type) ifFalse:[list add:type] |
1740 ]. |
1453 ]. |
1741 builder aspectAt:#rendererTypeList put:list. |
1454 builder aspectAt:#rendererTypeList put:list |
1742 |
|
1743 ]. |
1455 ]. |
1744 ^ list |
1456 ^list |
1745 ! |
1457 ! |
1746 |
1458 |
1747 selectedColumnModel |
1459 selectedColumnModel |
1748 "automatically generated by UIPainter ..." |
1460 "returns a value holder which keeps selected column" |
1749 |
1461 |
1750 |holder| |
1462 |holder| |
1751 |
1463 |
1752 (holder := builder bindingAt:#selectedColumnModel) isNil ifTrue:[ |
1464 (holder := builder bindingAt:#selectedColumnModel) isNil ifTrue:[ |
1753 holder := AspectAdaptor new subject:self; forAspect:#selectedColumnIndex. |
1465 holder := AspectAdaptor new subject:self; forAspect:#selectedColumnIndex. |
1802 ! ! |
1512 ! ! |
1803 |
1513 |
1804 !DataSetBuilder methodsFor:'change & update'! |
1514 !DataSetBuilder methodsFor:'change & update'! |
1805 |
1515 |
1806 update:something with:aParameter from:someObject |
1516 update:something with:aParameter from:someObject |
1807 "one of my aspects has changed; update modified channel |
1517 "one of my aspects has changed; update modified channel" |
1808 " |
1518 |
1809 |
1519 isModified |
1810 isModified ifFalse:[ |
1520 ifFalse: |
|
1521 [ |
1811 isModified := hasChanged := true. |
1522 isModified := hasChanged := true. |
1812 self modifiedChannel value:true. |
1523 self modifiedChannel value: true. |
1813 "self isNotModified value:false. " |
1524 self columnIsNotEditing value: false |
1814 ] |
1525 ] |
1815 ! ! |
1526 ! ! |
1816 |
1527 |
1817 !DataSetBuilder methodsFor:'code generation'! |
1528 !DataSetBuilder methodsFor:'code generation'! |
1818 |
1529 |
1819 compile:aCode forClass:aClass inCategory:aCategory |
1530 compile:aCode forClass:aClass inCategory:aCategory |
1820 "compile method for class in a category |
1531 "compile method for class in a category" |
1821 " |
1532 |
1822 ByteCodeCompiler compile:aCode withCRs forClass:aClass inCategory:aCategory |
1533 ByteCodeCompiler compile:aCode withCRs forClass:aClass inCategory:aCategory |
1823 ! |
1534 ! |
1824 |
1535 |
1825 generateBackgroundSelectorIn:aClass |
1536 generateBackgroundSelectorIn:aClass |
1826 "generate code for #backgroundSelector |
1537 "generate code for #backgroundSelector" |
1827 " |
1538 |
1828 |sel catg code bCode| |
1539 |sel catg code bCode| |
1829 |
1540 |
1830 catg := 'accessing look' asSymbol. |
1541 catg := 'accessing look' asSymbol. |
1831 code := '\' |
1542 code := '\' |
1832 , ' "automatically generated by DataSetBuilder ..."\' |
1543 , ' "automatically generated by DataSetBuilder ..."\' |
1833 , '\' |
1544 , '\' |
1834 , ' "specific background color for a cell"\' |
1545 , ' "specific background color for a cell"\' |
1835 , '\' |
1546 , '\' |
1836 . |
1547 . |
1837 |
1548 |
1838 columns do:[:aCol| |
1549 columns do: |
1839 ((sel := aCol backgroundSelector) notNil and:[(aClass implements:sel) not]) ifTrue:[ |
1550 [:aColumn| |
1840 bCode := sel asString, code, ' ^ nil'. |
1551 ((sel := aColumn backgroundSelector) notNil and:[(aClass implements:sel) not]) |
|
1552 ifTrue: |
|
1553 [ |
|
1554 bCode := sel asString, code, ' ^nil'. |
1841 self compile:bCode forClass:aClass inCategory:catg |
1555 self compile:bCode forClass:aClass inCategory:catg |
1842 ] |
1556 ] |
1843 ] |
1557 ] |
1844 |
1558 |
1845 |
1559 |
1846 ! |
1560 ! |
1847 |
1561 |
1848 generateChoicesIn:aClass |
1562 generateChoicesIn:aClass |
1849 "generate code for #choices |
1563 "generate code for #choices" |
1850 " |
1564 |
1851 |sel catg code| |
1565 |sel catg code| |
1852 |
1566 |
1853 catg := 'accessing menu' asSymbol. |
1567 catg := 'accessing menu' asSymbol. |
1854 code := '\' |
1568 code := '\' |
1855 , ' "automatically generated by DataSetBuilder ..."\' |
1569 , ' "automatically generated by DataSetBuilder ..."\' |
1856 , '\' |
1570 , '\' |
1857 , ' "get choices for visual editor; (a list of labels)\' |
1571 , ' "get choices for visual editor; (a list of labels)\' |
1858 , '\' |
1572 , '\' |
1859 , ' ^ nil' |
1573 , ' ^nil' |
1860 . |
1574 . |
1861 |
1575 |
1862 columns do:[:aColumn| |
1576 columns do: |
1863 ( aColumn canSelect |
1577 [:aColumn| |
1864 and:[aColumn rendererType ~~ #rowSelector |
1578 (aColumn canSelect |
1865 and:[(sel := aColumn choices) notNil |
1579 and:[aColumn rendererType ~~ #rowSelector |
1866 and:[(aClass implements:sel) not]]] |
1580 and:[(sel := aColumn choices) notNil |
1867 ) ifTrue:[ |
1581 and:[(aClass implements:sel) not]]]) |
|
1582 ifTrue: |
|
1583 [ |
1868 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1584 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1869 ] |
1585 ] |
1870 ] |
1586 ] |
1871 ! |
1587 ! |
1872 |
1588 |
1873 generateDoubleClickSelectorIn:aClass |
1589 generateDoubleClickSelectorIn:aClass |
1874 "generate code for #foregroundSelector |
1590 "generate code for #foregroundSelector" |
1875 " |
1591 |
1876 |sel catg code bCode| |
1592 |sel catg code bCode| |
1877 |
1593 |
1878 catg := 'accessing action' asSymbol. |
1594 catg := 'accessing action' asSymbol. |
1879 code := '\' |
1595 code := '\' |
1880 , ' "automatically generated by DataSetBuilder ..."\' |
1596 , ' "automatically generated by DataSetBuilder ..."\' |
1881 , '\' |
1597 , '\' |
1882 , ' "specific selector to be called on double click"\' |
1598 , ' "specific selector to be called on double click"\' |
1883 , '\' |
1599 , '\' |
1884 . |
1600 . |
1885 |
1601 |
1886 columns do:[:aCol| |
1602 columns do: |
1887 ((sel := aCol doubleClickedSelector) notNil and:[(aClass implements:sel) not]) ifTrue:[ |
1603 [:aColumn| |
|
1604 ((sel := aColumn doubleClickedSelector) notNil |
|
1605 and:[(aClass implements:sel) not]) |
|
1606 ifTrue: |
|
1607 [ |
1888 bCode := sel asString, code. |
1608 bCode := sel asString, code. |
1889 self compile:bCode forClass:aClass inCategory:catg |
1609 self compile:bCode forClass:aClass inCategory:catg |
1890 ] |
1610 ] |
1891 ] |
1611 ] |
1892 |
1612 |
1904 , '\' |
1624 , '\' |
1905 , ' "specific foreground color for a cell"\' |
1625 , ' "specific foreground color for a cell"\' |
1906 , '\' |
1626 , '\' |
1907 . |
1627 . |
1908 |
1628 |
1909 columns do:[:aCol| |
1629 columns do: |
1910 ((sel := aCol foregroundSelector) notNil and:[(aClass implements:sel) not]) ifTrue:[ |
1630 [:aColumn| |
1911 bCode := sel asString, code, ' ^ nil'. |
1631 ((sel := aColumn foregroundSelector) notNil |
|
1632 and:[(aClass implements:sel) not]) |
|
1633 ifTrue: |
|
1634 [ |
|
1635 bCode := sel asString, code, ' ^nil'. |
1912 self compile:bCode forClass:aClass inCategory:catg |
1636 self compile:bCode forClass:aClass inCategory:catg |
1913 ] |
1637 ] |
1914 ] |
1638 ] |
1915 |
1639 |
1916 |
1640 |
1917 ! |
1641 ! |
1918 |
1642 |
1919 generateMenuIn:aClass |
1643 generateMenuIn:aClass |
1920 "generate code for #menu |
1644 "generate code for #menu" |
1921 " |
1645 |
1922 |sel catg code| |
1646 |sel catg code| |
1923 |
1647 |
1924 catg := 'accessing menu' asSymbol. |
1648 catg := 'accessing menu' asSymbol. |
1925 code := '\' |
1649 code := '\' |
1926 , ' "automatically generated by DataSetBuilder ..."\' |
1650 , ' "automatically generated by DataSetBuilder ..."\' |
1927 , '\' |
1651 , '\' |
1928 , ' "get middleButton menu for selected cell in column"\' |
1652 , ' "get middleButton menu for selected cell in column"\' |
1929 , '\' |
1653 , '\' |
1930 , ' ^ nil' |
1654 , ' ^nil' |
1931 . |
1655 . |
1932 |
1656 |
1933 columns do:[:aColumn| |
1657 columns do: |
1934 ( aColumn canSelect |
1658 [:aColumn| |
1935 and:[(sel := aColumn menu) notNil |
1659 (aColumn canSelect |
1936 and:[(aClass implements:sel) not]] |
1660 and:[(sel := aColumn menu) notNil |
1937 ) ifTrue:[ |
1661 and:[(aClass implements:sel) not]]) |
|
1662 ifTrue: |
|
1663 [ |
1938 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1664 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1939 ] |
1665 ] |
1940 ] |
1666 ] |
1941 ! |
1667 ! |
1942 |
1668 |
1943 generatePrintSelectorIn:aClass |
1669 generatePrintSelectorIn:aClass |
1944 "generate code for #printSelector |
1670 "generate code for #printSelector" |
1945 " |
1671 |
1946 |sel catg code| |
1672 |sel catg code| |
1947 |
1673 |
1948 catg := 'accessing' asSymbol. |
1674 catg := 'accessing' asSymbol. |
1949 code := 'aGC\' |
1675 code := 'aGC\' |
1950 , ' "automatically generated by DataSetBuilder ..."\' |
1676 , ' "automatically generated by DataSetBuilder ..."\' |
1951 , '\' |
1677 , '\' |
1952 , ' "get drawable image or text on a gc"\' |
1678 , ' "get drawable image or text on a gc"\' |
1953 , '\' |
1679 , '\' |
1954 , ' ^ nil' |
1680 , ' ^nil' |
1955 . |
1681 . |
1956 |
1682 |
1957 columns do:[:aColumn| |
1683 columns do: |
1958 ( aColumn rendererType ~~ #rowSelector |
1684 [:aColumn| |
1959 and:[(sel := aColumn printSelector) notNil |
1685 (aColumn rendererType ~~ #rowSelector |
1960 and:[(aClass implements:sel) not]] |
1686 and:[(sel := aColumn printSelector) notNil |
1961 ) ifTrue:[ |
1687 and:[(aClass implements:sel) not]]) |
|
1688 ifTrue: |
|
1689 [ |
1962 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1690 self compile:(sel asString, code) forClass:aClass inCategory:catg |
1963 ] |
1691 ] |
1964 ] |
1692 ] |
1965 ! |
1693 ! |
1966 |
1694 |
1967 generateReadSelectorIn:aClass |
1695 generateReadSelectorIn:aClass |
1968 "generate code for #readSelector |
1696 "generate code for #readSelector" |
1969 " |
1697 |
1970 |sel catg code bCode| |
1698 |sel catg code bCode| |
1971 |
1699 |
1972 catg := 'accessing' asSymbol. |
1700 catg := 'accessing' asSymbol. |
1973 code := '\' |
1701 code := '\' |
1974 , ' "automatically generated by DataSetBuilder ..."\' |
1702 , ' "automatically generated by DataSetBuilder ..."\' |
1975 , '\' |
1703 , '\' |
1976 , ' "get value"\' |
1704 , ' "get value"\' |
1977 , '\' |
1705 , '\' |
1978 . |
1706 . |
1979 |
1707 |
1980 columns do:[:aColumn| |
1708 columns do: |
1981 ( aColumn rendererType ~~ #rowSelector |
1709 [:aColumn| |
1982 and:[(sel := aColumn readSelector) notNil |
1710 (aColumn rendererType ~~ #rowSelector |
1983 and:[(aClass implements:sel) not]] |
1711 and:[(sel := aColumn readSelector) notNil |
1984 ) ifTrue:[ |
1712 and:[(aClass implements:sel) not]]) |
1985 (aColumn printSelector isNil or:[aColumn canSelect]) ifTrue:[ |
1713 ifTrue: |
1986 sel numArgs == 0 ifTrue:[ |
1714 [ |
1987 bCode := sel asString, code |
1715 (aColumn printSelector isNil or:[aColumn canSelect]) |
1988 ] ifFalse:[ |
1716 ifTrue: |
1989 bCode := sel asString, 'anIndex\', code |
1717 [ |
1990 ]. |
1718 sel numArgs == 0 |
1991 aColumn rendererType == #CheckToggle ifFalse:[ |
1719 ifTrue: [bCode := sel asString, code] |
1992 bCode := bCode, ' ^ nil' |
1720 ifFalse:[bCode := sel asString, 'anIndex\', code]. |
1993 ] ifTrue:[ |
1721 aColumn rendererType == #CheckToggle |
1994 bCode := bCode, ' ^ true' |
1722 ifFalse:[bCode := bCode, ' ^nil'] |
1995 ]. |
1723 ifTrue: [bCode := bCode, ' ^true']. |
1996 self compile:bCode forClass:aClass inCategory:catg |
1724 self compile:bCode forClass:aClass inCategory:catg |
1997 ] |
1725 ] |
1998 ] |
1726 ] |
1999 ] |
1727 ] |
2000 ! |
1728 ! |
2010 , '\' |
1738 , '\' |
2011 , ' "can select cell in column"\' |
1739 , ' "can select cell in column"\' |
2012 , '\' |
1740 , '\' |
2013 . |
1741 . |
2014 |
1742 |
2015 columns do:[:aColumn| |
1743 columns do: |
2016 ( aColumn rendererType ~~ #rowSelector |
1744 [:aColumn| |
|
1745 (aColumn rendererType ~~ #rowSelector |
2017 and:[(sel := aColumn selectSelector) notNil |
1746 and:[(sel := aColumn selectSelector) notNil |
2018 and:[(aClass implements:sel) not]] |
1747 and:[(aClass implements:sel) not]]) |
2019 ) ifTrue:[ |
1748 ifTrue: |
2020 aColumn canSelect ifTrue:[ |
1749 [ |
2021 bCode := sel asString, code, ' ^ true'. |
1750 aColumn canSelect |
|
1751 ifTrue: |
|
1752 [ |
|
1753 bCode := sel asString, code, ' ^true'. |
2022 self compile:bCode forClass:aClass inCategory:catg |
1754 self compile:bCode forClass:aClass inCategory:catg |
2023 ] |
1755 ] |
2024 ] |
1756 ] |
2025 ] |
1757 ] |
2026 ! |
1758 ! |
2027 |
1759 |
2028 generateWriteSelectorIn:aClass |
1760 generateWriteSelectorIn:aClass |
2029 "generate code for #writeSelector |
1761 "generate code for #writeSelector" |
2030 " |
1762 |
2031 |sel catg code bCode sz| |
1763 |sel catg code bCode sz| |
2032 |
1764 |
2033 catg := 'accessing' asSymbol. |
1765 catg := 'accessing' asSymbol. |
2034 code := 'aValue\' |
1766 code := 'aValue\' |
2035 , ' "automatically generated by DataSetBuilder ..."\' |
1767 , ' "automatically generated by DataSetBuilder ..."\' |
2036 , '\' |
1768 , '\' |
2037 , ' "set value"\' |
1769 , ' "set value"\' |
2038 . |
1770 . |
2039 |
1771 |
2040 columns do:[:aColumn| |
1772 columns do: |
2041 ( (sel := aColumn writeSelector) notNil |
1773 [:aColumn| |
2042 and:[(aColumn canSelect) |
1774 ((sel := aColumn writeSelector) notNil |
2043 and:[(aClass implements:sel) not]] |
1775 and:[aColumn canSelect |
2044 ) ifTrue:[ |
1776 and:[(aClass implements:sel) not]]) |
2045 sel numArgs == 1 ifTrue:[ |
1777 ifTrue: |
|
1778 [ |
|
1779 sel numArgs == 1 |
|
1780 ifTrue: |
|
1781 [ |
2046 bCode := sel asString |
1782 bCode := sel asString |
2047 ] ifFalse:[ |
1783 ] |
|
1784 ifFalse: |
|
1785 [ |
2048 sz := sel indexOf:$:. |
1786 sz := sel indexOf:$:. |
2049 bCode := sel copyTo:sz. |
1787 bCode := sel copyTo:sz. |
2050 bCode := bCode, 'anIndex ', (sel copyFrom:(sz + 1)). |
1788 bCode := bCode, 'anIndex ', (sel copyFrom:sz + 1) |
2051 ]. |
1789 ]. |
2052 self compile:(bCode, code) forClass:aClass inCategory:catg |
1790 self compile:(bCode, code) forClass:aClass inCategory:catg |
2053 ] |
1791 ] |
2054 ] |
1792 ] |
2055 ! ! |
1793 ! ! |
2056 |
1794 |
2057 !DataSetBuilder methodsFor:'initialization'! |
1795 !DataSetBuilder methodsFor:'initialization'! |
2058 |
1796 |
2059 initialize |
1797 initialize |
2060 "setup aspects used by column description specifications |
1798 "setup aspects used by column description specifications" |
2061 " |
1799 |
2062 |holder| |
1800 |holder| |
2063 |
1801 |
2064 super initialize. |
1802 super initialize. |
2065 selectedColumnIndex := 0. |
1803 selectedColumnIndex := 0. |
2066 tabSelectionIndex := 0. |
1804 tabSelectionIndex := 0. |
2125 ^true |
1863 ^true |
2126 |
1864 |
2127 ! |
1865 ! |
2128 |
1866 |
2129 resolveClassNamed |
1867 resolveClassNamed |
2130 "returns current class or nil |
1868 "returns current class or nil" |
2131 " |
1869 |
2132 ^ Smalltalk resolveName:className inClass:self class. |
1870 ^Smalltalk resolveName:className inClass:self class. |
2133 |
1871 |
2134 ! |
1872 ! |
2135 |
1873 |
2136 updateColumnView |
1874 updateColumnView |
2137 "update column view from column descriptions |
1875 "update column view from column descriptions" |
2138 " |
1876 |
2139 columnView notNil ifTrue:[ |
1877 columnView notNil ifTrue:[columnView columnDescriptors:columns] |
2140 columnView columnDescriptors:columns. |
1878 ! |
2141 ]. |
1879 |
|
1880 updateInputFields |
|
1881 "reload item value into input fields" |
|
1882 |
|
1883 |column| |
|
1884 |
|
1885 (column := self selectedColumn) isNil |
|
1886 ifTrue: |
|
1887 [ |
|
1888 self tabModel value:0. |
|
1889 ] |
|
1890 ifFalse: |
|
1891 [ |
|
1892 aspects keysAndValuesDo:[:aKey :aModel|aModel value:(column perform:aKey)]. |
|
1893 tabSelectionIndex == 0 ifTrue:[self tabModel value:1] |
|
1894 ] |
2142 ! ! |
1895 ! ! |
2143 |
1896 |
2144 !DataSetBuilder methodsFor:'queries'! |
1897 !DataSetBuilder methodsFor:'queries'! |
2145 |
1898 |
2146 hasChanged |
1899 hasChanged |
2147 "returns true if changes are done to the original column description |
1900 "returns true if changes are done to the original column description" |
2148 " |
1901 |
2149 ^ hasChanged |
1902 ^hasChanged |
2150 ! |
|
2151 |
|
2152 modified |
|
2153 "returns true if current specification is modified |
|
2154 " |
|
2155 ^ self modifiedChannel value |
|
2156 ! ! |
1903 ! ! |
2157 |
1904 |
2158 !DataSetBuilder methodsFor:'selection'! |
1905 !DataSetBuilder methodsFor:'selection'! |
2159 |
1906 |
2160 selectedColumn |
1907 selectedColumn |
2161 "returns selected column or nil |
1908 "returns selected column or nil" |
2162 " |
1909 |
2163 ^ selectedColumnIndex == 0 ifFalse:[columns at:selectedColumnIndex] |
1910 ^selectedColumnIndex == 0 |
2164 ifTrue:[nil] |
1911 ifFalse:[columns at:selectedColumnIndex] |
|
1912 ifTrue: [nil] |
2165 ! |
1913 ! |
2166 |
1914 |
2167 selectedColumnIndex |
1915 selectedColumnIndex |
2168 "returns selected column index or 0 |
1916 "returns selected column index or 0" |
2169 " |
1917 |
2170 ^ selectedColumnIndex |
1918 ^selectedColumnIndex |
2171 ! |
1919 ! |
2172 |
1920 |
2173 selectedColumnIndex:something |
1921 selectedColumnIndex:something |
2174 "change selected column and update specifications |
1922 "change selected column and update specifications" |
2175 " |
1923 |
2176 something == selectedColumnIndex ifFalse:[ |
1924 something == selectedColumnIndex |
|
1925 ifFalse: |
|
1926 [ |
2177 selectedColumnIndex := something ? 0. |
1927 selectedColumnIndex := something ? 0. |
2178 self cancel. |
|
2179 self isColumnSelected value: true |
1928 self isColumnSelected value: true |
2180 ]. |
1929 ] |
2181 |
1930 |
2182 ! |
1931 ! |
2183 |
1932 |
2184 tabSelectionIndex |
1933 tabSelectionIndex |
2185 "returns selected tab index or 0 |
1934 "returns selected tab index or 0" |
2186 " |
1935 |
2187 ^ tabSelectionIndex |
1936 ^tabSelectionIndex |
2188 ! |
1937 ! |
2189 |
1938 |
2190 tabSelectionIndex:something |
1939 tabSelectionIndex:something |
2191 "change selected tab and set corresponding specification |
1940 "change selected tab and set corresponding specification" |
2192 " |
1941 |
2193 |specSelector| |
1942 |specSelector| |
2194 |
1943 |
2195 something == tabSelectionIndex ifTrue:[ |
1944 something == tabSelectionIndex ifTrue:[^self]. |
2196 ^ self |
1945 self selectedColumn isNil |
2197 ]. |
1946 ifTrue: |
2198 self selectedColumn isNil ifTrue:[ |
1947 [ |
2199 tabSelectionIndex == 0 ifTrue:[^ self ]. |
1948 tabSelectionIndex == 0 ifTrue:[^self]. |
2200 tabSelectionIndex := 0 |
1949 tabSelectionIndex := 0 |
2201 ] ifFalse:[ |
1950 ] |
2202 (tabSelectionIndex := something) ~~ 0 ifTrue:[ |
1951 ifFalse: |
2203 specSelector := (self class slices at:tabSelectionIndex) last. |
1952 [ |
2204 ] |
1953 (tabSelectionIndex := something) ~~ 0 |
|
1954 ifTrue: [specSelector := (self class slices at:tabSelectionIndex) last] |
2205 ]. |
1955 ]. |
2206 self specChannel value:specSelector |
1956 self specChannel value:specSelector |
2207 |
1957 |
2208 |
1958 |
2209 ! ! |
1959 ! ! |
2210 |
1960 |
2211 !DataSetBuilder methodsFor:'startup / release'! |
1961 !DataSetBuilder methodsFor:'startup / release'! |
2212 |
1962 |
2213 closeRequest |
1963 closeRequest |
2214 "close request |
1964 "close request" |
2215 " |
1965 |
2216 self checkMenuItemModified ifTrue: [super closeRequest] |
1966 self checkMenuItemModified ifTrue: [super closeRequest] |
2217 ! |
1967 ! |
2218 |
1968 |
2219 postBuildWith:builder |
1969 postBuildWith:builder |
2220 |
1970 |
2221 super postBuildWith:builder. |
1971 super postBuildWith:builder. |
2222 |
1972 |
2223 (builder componentAt: #columnView) |
1973 (builder componentAt: #columnView) |
2224 selectConditionBlock: [:i|self checkMenuItemModified]; |
1974 selectConditionBlock: [:i|self checkMenuItemModified]; |
|
1975 action: [:i|self cancel]; |
2225 selection: 1 |
1976 selection: 1 |
2226 |
1977 |
2227 |
1978 |
|
1979 |
|
1980 ! ! |
|
1981 |
|
1982 !DataSetBuilder methodsFor:'user actions'! |
|
1983 |
|
1984 accept |
|
1985 "accept changes made" |
|
1986 |
|
1987 |column type| |
|
1988 |
|
1989 self modifiedChannel value == false ifTrue: [^self]. |
|
1990 isModified := true. |
|
1991 |
|
1992 (column := self selectedColumn) isNil ifTrue: [^self cancel]. |
|
1993 |
|
1994 type := (aspects at:#rendererType) value. |
|
1995 |
|
1996 type == #rowSelector |
|
1997 ifTrue: |
|
1998 [ |
|
1999 #(label width minWidth editorType choices readSelector writeSelector printSelector |
|
2000 formatString type size height canSelect selectSelector) do:[:aKey|(aspects at:aKey) value:nil] |
|
2001 ]. |
|
2002 |
|
2003 aspects keysAndValuesDo:[:aKey :aModel| column perform:(aKey , ':') asSymbol with: aModel value]. |
|
2004 self seqList at:selectedColumnIndex put: (aspects at:#label) value. |
|
2005 self updateColumnView. |
|
2006 self cancel |
|
2007 ! |
|
2008 |
|
2009 cancel |
|
2010 "remove all changes and reload selected column values" |
|
2011 |
|
2012 |column| |
|
2013 |
|
2014 self updateInputFields. |
|
2015 self modifiedChannel value:false. |
|
2016 self columnIsNotEditing value: true. |
|
2017 isModified := false |
|
2018 ! |
|
2019 |
|
2020 doBrowseClass |
|
2021 "browse class of columns spec" |
|
2022 |
|
2023 |cls| |
|
2024 |
|
2025 (cls := self resolveClassNamed) notNil |
|
2026 ifTrue: [SystemBrowser openInClass:cls] |
|
2027 ifFalse:[self information:'No class defined!!'] |
|
2028 |
|
2029 |
|
2030 |
|
2031 ! |
|
2032 |
|
2033 doCopyColumn |
|
2034 "copy selected column to the clipboard" |
|
2035 |
|
2036 |idx| |
|
2037 |
|
2038 (idx := selectedColumnIndex) ~~ 0 |
|
2039 ifTrue: |
|
2040 [ |
|
2041 self clipboard: (columns at: idx) deepCopy |
|
2042 ] |
|
2043 ! |
|
2044 |
|
2045 doCreateColumn |
|
2046 "create a new column after selected column or at left (nothing selected)" |
|
2047 |
|
2048 |label list| |
|
2049 |
|
2050 list := self seqList. |
|
2051 label := 'Column ', list size printString. |
|
2052 columns add:(DataSetColumnSpec label:label selector:nil) afterIndex:selectedColumnIndex. |
|
2053 self seqList add:label afterIndex:selectedColumnIndex. |
|
2054 hasChanged := true. |
|
2055 self modifiedChannel value ifFalse:[self selectedColumnModel value:selectedColumnIndex + 1]. |
|
2056 self cancel |
|
2057 |
|
2058 ! |
|
2059 |
|
2060 doCutColumn |
|
2061 "remove selected column and put it to the clipboard" |
|
2062 |
|
2063 |idx| |
|
2064 |
|
2065 ((idx := selectedColumnIndex) ~~ 0 and: [self checkMenuItemModified]) |
|
2066 ifTrue: |
|
2067 [ |
|
2068 self selectedColumnModel value:0. |
|
2069 self clipboard: (columns at: idx). |
|
2070 columns removeIndex:idx. |
|
2071 self seqList removeIndex:idx. |
|
2072 self updateColumnView. |
|
2073 columns isEmpty ifTrue: [self isColumnSelected value: false]. |
|
2074 hasChanged := true |
|
2075 ] |
|
2076 ! |
|
2077 |
|
2078 doDefineClass |
|
2079 "launch a dialog to define class and superclass" |
|
2080 |
|
2081 |aspects cls oldClass oldSuper| |
|
2082 |
|
2083 aspects := IdentityDictionary new. |
|
2084 oldClass := className. |
|
2085 oldSuper := superclassName. |
|
2086 |
|
2087 [true] |
|
2088 whileTrue: |
|
2089 [ |
|
2090 className notNil |
|
2091 ifTrue: |
|
2092 [ |
|
2093 (cls := self resolveClassNamed) notNil |
|
2094 ifTrue: |
|
2095 [ |
|
2096 superclassName := cls superclass name asString |
|
2097 ]. |
|
2098 aspects at:#classNameChannel put:className asValue |
|
2099 ] |
|
2100 ifFalse: |
|
2101 [ |
|
2102 aspects at:#classNameChannel put:'DSVRow' asValue |
|
2103 ]. |
|
2104 |
|
2105 superclassName notNil |
|
2106 ifTrue: [aspects at:#superclassNameChannel put:superclassName asValue] |
|
2107 ifFalse:[aspects at:#superclassNameChannel put:'Object' asValue]. |
|
2108 |
|
2109 (self openDialogInterface:#defineClassNameSpec withBindings:aspects) |
|
2110 ifFalse: |
|
2111 [ |
|
2112 className := oldClass. |
|
2113 superclassName := oldSuper. |
|
2114 ^self |
|
2115 ]. |
|
2116 className := ((aspects at:#classNameChannel) value) withoutSeparators. |
|
2117 superclassName := ((aspects at:#superclassNameChannel) value) withoutSeparators. |
|
2118 |
|
2119 className size == 0 |
|
2120 ifTrue: |
|
2121 [ |
|
2122 className := nil. |
|
2123 self information:'no valid className' |
|
2124 ] |
|
2125 ifFalse: |
|
2126 [ |
|
2127 cls := self resolveClassNamed. |
|
2128 |
|
2129 cls notNil ifTrue:[cls := cls superclass name asString]. |
|
2130 |
|
2131 superclassName size == 0 |
|
2132 ifTrue: |
|
2133 [ |
|
2134 cls notNil ifTrue:[ |
|
2135 superclassName := cls |
|
2136 ] ifFalse:[ |
|
2137 superclassName := 'Object' |
|
2138 ]. |
|
2139 self information: 'set superclassName' |
|
2140 ] |
|
2141 ifFalse: |
|
2142 [ |
|
2143 (cls isNil or:[superclassName = cls]) ifTrue:[hasChanged := true. ^self]. |
|
2144 self information:('A global named ' , className , ' exists,\' , |
|
2145 'but is not a subclass of ' , superclassName, '.\\' , |
|
2146 'Check and try again if that is not what you want.') withCRs. |
|
2147 |
|
2148 superclassName := cls |
|
2149 ] |
|
2150 ] |
|
2151 ] |
|
2152 ! |
|
2153 |
|
2154 doGenerateCode |
|
2155 "generate code for column values" |
|
2156 |
|
2157 |cls superclass| |
|
2158 |
|
2159 className isNil ifTrue:[^self information:'No class defined!!']. |
|
2160 cls := self resolveClassNamed. |
|
2161 |
|
2162 cls isNil |
|
2163 ifTrue: |
|
2164 [ |
|
2165 superclass := Smalltalk resolveName:superclassName inClass:self class. |
|
2166 |
|
2167 superclass isNil ifTrue:[^self information:'No superclass defined!!']. |
|
2168 (self confirm:'create ' , className , ' ?') ifFalse:[^self]. |
|
2169 cls := superclass subclass:className asSymbol |
|
2170 instanceVariableNames:'' |
|
2171 classVariableNames:'' |
|
2172 poolDictionaries:'' |
|
2173 category:'Applications'. |
|
2174 ]. |
|
2175 |
|
2176 self generateChoicesIn:cls. |
|
2177 self generateMenuIn:cls. |
|
2178 self generatePrintSelectorIn:cls. |
|
2179 self generateReadSelectorIn:cls. |
|
2180 self generateBackgroundSelectorIn:cls. |
|
2181 self generateForegroundSelectorIn:cls. |
|
2182 self generateSelectSelectorIn:cls. |
|
2183 self generateWriteSelectorIn:cls. |
|
2184 self generateDoubleClickSelectorIn:cls. |
|
2185 ! |
|
2186 |
|
2187 doMoveColumn:upOrDown |
|
2188 "move selected column up or down" |
|
2189 |
|
2190 |idx list label col size| |
|
2191 |
|
2192 (idx := selectedColumnIndex) == 0 ifTrue:[^self]. |
|
2193 list := self seqList. |
|
2194 size := list size. |
|
2195 |
|
2196 size == 1 ifTrue:[^self]. |
|
2197 hasChanged := true. |
|
2198 selectedColumnIndex := 0. |
|
2199 label := list at:idx. |
|
2200 col := columns at:idx. |
|
2201 list removeIndex:idx. |
|
2202 columns removeIndex:idx. |
|
2203 |
|
2204 upOrDown == #up |
|
2205 ifTrue: |
|
2206 [ |
|
2207 idx == 1 ifTrue:[idx := size] |
|
2208 ifFalse:[idx := idx - 1] |
|
2209 ] |
|
2210 ifFalse: |
|
2211 [ |
|
2212 idx == size ifTrue:[idx := 1] |
|
2213 ifFalse:[idx := idx + 1] |
|
2214 ]. |
|
2215 columns add:col beforeIndex:idx. |
|
2216 list add:label beforeIndex:idx. |
|
2217 self selectedColumnModel value:idx. |
|
2218 self updateColumnView. |
|
2219 ! |
|
2220 |
|
2221 doPasteColumn |
|
2222 "paste clipboard copy column after selected column or at left (nothing selected)" |
|
2223 |
|
2224 |label list| |
|
2225 |
|
2226 list := self seqList. |
|
2227 label := self class clipboard label. |
|
2228 columns add: self class clipboard deepCopy afterIndex:selectedColumnIndex. |
|
2229 self seqList add: label afterIndex:selectedColumnIndex. |
|
2230 hasChanged := true. |
|
2231 |
|
2232 self modifiedChannel value ifFalse:[self selectedColumnModel value:selectedColumnIndex + 1]. |
|
2233 self updateColumnView. |
2228 |
2234 |
2229 ! ! |
2235 ! ! |
2230 |
2236 |
2231 !DataSetBuilder class methodsFor:'documentation'! |
2237 !DataSetBuilder class methodsFor:'documentation'! |
2232 |
2238 |