HierarchicalListEditor.st
author Claus Gittinger <cg@exept.de>
Tue, 14 May 2019 09:46:21 +0200
changeset 3663 9d49ecf8661a
parent 3306 a2d6e8a1bcaf
permissions -rw-r--r--
#UI_ENHANCEMENT by cg
class: TabListEditor class
changed:
#canvasSpec
#menu
#windowSpec
ca@300
     1
"
tz@736
     2
 COPYRIGHT (c) 1997 by eXept Software AG
ca@300
     3
              All Rights Reserved
ca@300
     4
ca@300
     5
 This software is furnished under a license and may be used
ca@300
     6
 only in accordance with the terms of that license and with the
tz@736
     7
 inclusion of the above copyright notice. This software may not
ca@300
     8
 be provided or otherwise made available to, or used by, any
ca@300
     9
 other person.  No title to or ownership of the software is
ca@300
    10
 hereby transferred.
ca@300
    11
"
mawalch@3306
    12
"{ Package: 'stx:libtool2' }"
ca@300
    13
mawalch@3306
    14
"{ NameSpace: Smalltalk }"
cg@1499
    15
tz@736
    16
ResourceSpecEditor subclass:#HierarchicalListEditor
tz@731
    17
	instanceVariableNames:'treeView'
tz@731
    18
	classVariableNames:''
ca@300
    19
	poolDictionaries:''
ca@300
    20
	category:'Interface-UIPainter'
ca@300
    21
!
ca@300
    22
ca@300
    23
!HierarchicalListEditor class methodsFor:'documentation'!
ca@300
    24
ca@300
    25
copyright
ca@300
    26
"
tz@736
    27
 COPYRIGHT (c) 1997 by eXept Software AG
ca@300
    28
              All Rights Reserved
ca@300
    29
ca@300
    30
 This software is furnished under a license and may be used
ca@300
    31
 only in accordance with the terms of that license and with the
tz@736
    32
 inclusion of the above copyright notice. This software may not
ca@300
    33
 be provided or otherwise made available to, or used by, any
ca@300
    34
 other person.  No title to or ownership of the software is
ca@300
    35
 hereby transferred.
ca@300
    36
"
ca@300
    37
ca@300
    38
ca@300
    39
ca@300
    40
!
ca@300
    41
ca@300
    42
documentation
ca@300
    43
"
tz@731
    44
    The HierarchicalListEditor allows you to create, modify or just inspect
tz@731
    45
    (statical) hierarchical lists for the SelectionInListView.
ca@300
    46
ca@300
    47
    [start with:]
ca@300
    48
        HierarchicalListEditor open
ca@300
    49
ca@300
    50
    [see also:]
ca@300
    51
        UIPainter
ca@300
    52
ca@300
    53
    [author:]
tz@546
    54
        Claus Atzkern, eXept Software AG
tz@731
    55
        Thomas Zwick, eXept Software AG
ca@300
    56
"
ca@300
    57
ca@300
    58
ca@300
    59
ca@300
    60
! !
ca@300
    61
tz@731
    62
!HierarchicalListEditor class methodsFor:'instance creation'!
tz@731
    63
tz@731
    64
openModalOnTreeItem: aTreeItem
tz@731
    65
    "Open a HierarchicalListEditor modal on aTreeItem"
tz@731
    66
    "self openModalOnTreeItem: (TreeItem name: 'Label' contents: #Contents)"
tz@731
    67
tz@731
    68
    ^self new openModalOnTreeItem: aTreeItem
tz@731
    69
tz@731
    70
! !
tz@731
    71
tz@731
    72
!HierarchicalListEditor class methodsFor:'accessing'!
tz@731
    73
tz@731
    74
resourceType
tz@731
    75
    "get the type of resource of the method generated by the HierarchicalListEditor"
tz@731
    76
tz@731
    77
    ^#hierarchicalList
tz@731
    78
tz@731
    79
! !
tz@731
    80
tz@551
    81
!HierarchicalListEditor class methodsFor:'help specs'!
tz@551
    82
tz@551
    83
helpSpec
tz@736
    84
    "This resource specification was automatically generated
tz@736
    85
     by the UIHelpTool of ST/X."
tz@736
    86
tz@736
    87
    "Do not manually edit this!! If it is corrupted,
tz@736
    88
     the UIHelpTool may not be able to read the specification."
tz@551
    89
tz@551
    90
    "
tz@736
    91
     UIHelpTool openOnClass:HierarchicalListEditor    
tz@551
    92
    "
tz@551
    93
tz@736
    94
    <resource: #help>
tz@736
    95
tz@736
    96
    ^super helpSpec addPairsFrom:#(
tz@551
    97
tz@551
    98
#addChild
tz@551
    99
'Adds a new child item.'
tz@551
   100
tz@551
   101
#addSister
tz@551
   102
'Adds a new sister item.'
tz@551
   103
tz@581
   104
#contents
tz@581
   105
'Contents of the tree item.'
tz@581
   106
tz@731
   107
#fileLoad
tz@731
   108
'Opens a dialog for selecting and loading a hierarchical list spec from a class.'
tz@731
   109
tz@551
   110
#fileNew
tz@736
   111
'Creates a new hierarchical list. '
tz@551
   112
tz@731
   113
#fileSave
tz@731
   114
'Saves current hierarchical list spec.'
tz@552
   115
tz@731
   116
#fileSaveAs
tz@731
   117
'Opens a dialog to save current hierarchical list spec.'
tz@552
   118
tz@581
   119
#label
tz@581
   120
'Label of the tree item.'
tz@581
   121
tz@551
   122
)
tz@551
   123
! !
tz@551
   124
tz@731
   125
!HierarchicalListEditor class methodsFor:'image specs'!
ca@300
   126
tz@731
   127
createChildIcon
tz@736
   128
    "This resource specification was automatically generated
tz@736
   129
     by the ImageEditor of ST/X."
tz@736
   130
tz@736
   131
    "Do not manually edit this!! If it is corrupted,
tz@736
   132
     the ImageEditor may not be able to read the specification."
tz@736
   133
ca@300
   134
    "
tz@736
   135
     ImageEditor openOnClass:self andSelector:#createChildIcon
ca@300
   136
    "
ca@300
   137
tz@731
   138
    <resource: #image>
ca@300
   139
tz@731
   140
    ^Icon
tz@731
   141
        constantNamed:#'HierarchicalListEditor createChildIcon'
cg@1499
   142
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@AUUUUP@@A????2@@A????2 @A????0@@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A<3L308@A33L33H@A30L33H@A33L33H@A<3L008@A?????8@C*****(@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@_??@_?? _??0_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8') ; yourself); yourself]
cg@1499
   143
!
tz@731
   144
tz@731
   145
createSisterIcon
tz@736
   146
    "This resource specification was automatically generated
tz@736
   147
     by the ImageEditor of ST/X."
tz@736
   148
tz@736
   149
    "Do not manually edit this!! If it is corrupted,
tz@736
   150
     the ImageEditor may not be able to read the specification."
tz@736
   151
tz@731
   152
    "
tz@736
   153
     ImageEditor openOnClass:self andSelector:#createSisterIcon
tz@731
   154
    "
tz@731
   155
tz@731
   156
    <resource: #image>
tz@731
   157
tz@731
   158
    ^Icon
tz@731
   159
        constantNamed:#'HierarchicalListEditor createSisterIcon'
cg@1499
   160
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@AUUUUP@@A????2@@A????2 @A????0@@A?????8@A?????8@A?????8@A<L<O?8@A3<3??8@A<<<<C8@A?L?O?8@A0<0??8@A?????8@A0LCC?8@A<<?L?8@A<<CC?8@A<<?L?8@A<<CL?8@A?????8@C*****(@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@_??@_?? _??0_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8') ; yourself); yourself]
cg@1499
   161
! !
tz@731
   162
tz@731
   163
!HierarchicalListEditor class methodsFor:'interface specs'!
ca@300
   164
ca@300
   165
windowSpec
tz@736
   166
    "This resource specification was automatically generated
tz@736
   167
     by the UIPainter of ST/X."
ca@300
   168
tz@736
   169
    "Do not manually edit this!! If it is corrupted,
tz@736
   170
     the UIPainter may not be able to read the specification."
ca@300
   171
ca@300
   172
    "
ca@300
   173
     UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec
ca@300
   174
     HierarchicalListEditor new openInterface:#windowSpec
tz@736
   175
     HierarchicalListEditor open
ca@300
   176
    "
ca@300
   177
ca@300
   178
    <resource: #canvas>
ca@300
   179
cg@1686
   180
    ^ 
cg@1686
   181
     #(#FullSpec
cg@1686
   182
        #name: #windowSpec
cg@1686
   183
        #window: 
cg@1686
   184
       #(#WindowSpec
cg@1686
   185
          #label: 'Hierarchical List Editor'
cg@1686
   186
          #name: 'Hierarchical List Editor'
cg@1686
   187
          #min: #(#Point 450 280)
cg@1686
   188
          #max: #(#Point 1152 900)
cg@1686
   189
          #bounds: #(#Rectangle 16 46 486 376)
cg@1686
   190
          #menu: #menu
cg@1686
   191
        )
cg@1686
   192
        #component: 
cg@1686
   193
       #(#SpecCollection
cg@1686
   194
          #collection: #(
cg@1686
   195
           #(#MenuPanelSpec
cg@1686
   196
              #name: 'menuToolbarView'
cg@1686
   197
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 32 0)
cg@1686
   198
              #menu: #menuToolbar
cg@1686
   199
            )
cg@1686
   200
           #(#VariableHorizontalPanelSpec
cg@1686
   201
              #name: 'VariableHorizontalPanel'
cg@1686
   202
              #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
cg@1686
   203
              #component: 
cg@1686
   204
             #(#SpecCollection
cg@1686
   205
                #collection: #(
cg@1686
   206
                 #(#ArbitraryComponentSpec
cg@1686
   207
                    #name: 'TreeView'
cg@1686
   208
                    #menu: #menuEdit
cg@1686
   209
                    #hasHorizontalScrollBar: true
cg@1686
   210
                    #hasVerticalScrollBar: true
cg@1686
   211
                    #miniScrollerHorizontal: true
cg@1686
   212
                    #miniScrollerVertical: true
cg@1686
   213
                    #hasBorder: false
cg@1686
   214
                    #component: #treeView
cg@1686
   215
                  )
cg@1686
   216
                 #(#ViewSpec
cg@1686
   217
                    #name: 'SpecView'
cg@1686
   218
                    #level: -1
tz@731
   219
                    #component: 
cg@1686
   220
                   #(#SpecCollection
cg@1686
   221
                      #collection: #(
cg@1686
   222
                       #(#LabelSpec
cg@1686
   223
                          #label: 'Label:'
cg@1686
   224
                          #name: 'nameLabel'
cg@1686
   225
                          #layout: #(#AlignmentOrigin 98 0 26 0 1 0.5)
cg@1686
   226
                          #resizeForLabel: true
cg@1875
   227
                    translateLabel: true
ca@300
   228
                        )
cg@1686
   229
                       #(#InputFieldSpec
cg@1686
   230
                          #name: 'labelInputField'
cg@1686
   231
                          #layout: #(#LayoutFrame 100 0 15 0 -5 1.0 37 0)
cg@1686
   232
                          #activeHelpKey: #label
cg@1686
   233
                          #tabable: true
cg@1686
   234
                          #model: #itemName
cg@1686
   235
                          #acceptOnLeave: true
cg@1686
   236
                          #acceptOnLostFocus: true
cg@1686
   237
                          #acceptChannel: #acceptChannel
cg@1686
   238
                          #modifiedChannel: #modifiedChannel
cg@1686
   239
                          #acceptOnPointerLeave: true
cg@1686
   240
                        )
cg@1686
   241
                       #(#LabelSpec
cg@1686
   242
                          #label: 'Contents:'
cg@1686
   243
                          #name: 'valueLabel'
cg@1686
   244
                          #layout: #(#AlignmentOrigin 98 0 52 0 1 0.5)
cg@1686
   245
                          #activeHelpKey: #contents
cg@1686
   246
                          #resizeForLabel: true
cg@1875
   247
                    translateLabel: true
cg@1686
   248
                        )
cg@1686
   249
                       #(#InputFieldSpec
cg@1686
   250
                          #name: 'valueInputField'
cg@1686
   251
                          #layout: #(#LayoutFrame 100 0 41 0 -5 1.0 63 0)
cg@1686
   252
                          #activeHelpKey: #contents
cg@1686
   253
                          #tabable: true
cg@1686
   254
                          #model: #itemValue
cg@1686
   255
                          #type: #smalltalkObject
cg@1686
   256
                          #acceptOnLeave: true
cg@1686
   257
                          #acceptOnLostFocus: true
cg@1686
   258
                          #acceptChannel: #acceptChannel
cg@1686
   259
                          #modifiedChannel: #modifiedChannel
cg@1686
   260
                          #acceptOnPointerLeave: true
cg@1686
   261
                        )
cg@1686
   262
                       #(#UISubSpecification
cg@1686
   263
                          #name: 'SubSpecification'
cg@1686
   264
                          #layout: #(#LayoutFrame 2 0.0 -26 1.0 -2 1.0 -2 1.0)
cg@1686
   265
                          #majorKey: #ToolApplicationModel
cg@1686
   266
                          #minorKey: #windowSpecForCommit
cg@1686
   267
                        )
cg@1686
   268
                       )
cg@1686
   269
                     
ca@300
   270
                    )
cg@1686
   271
                  )
cg@1686
   272
                 )
cg@1686
   273
               
ca@300
   274
              )
cg@1686
   275
              #handles: #(#Any 0.368421 1.0)
cg@1686
   276
            )
cg@1686
   277
           #(#UISubSpecification
cg@1686
   278
              #name: 'InfoBarSubSpec'
cg@1686
   279
              #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
cg@1686
   280
              #majorKey: #ToolApplicationModel
cg@1686
   281
              #minorKey: #windowSpecForInfoBar
cg@1686
   282
            )
cg@1686
   283
           )
cg@1686
   284
         
cg@1686
   285
        )
ca@300
   286
      )
ca@300
   287
! !
ca@300
   288
tz@506
   289
!HierarchicalListEditor class methodsFor:'menu specs'!
tz@506
   290
tz@506
   291
menu
tz@736
   292
    "This resource specification was automatically generated
tz@736
   293
     by the MenuEditor of ST/X."
tz@506
   294
tz@736
   295
    "Do not manually edit this!! If it is corrupted,
tz@736
   296
     the MenuEditor may not be able to read the specification."
tz@506
   297
tz@506
   298
    "
tz@506
   299
     MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menu
tz@506
   300
     (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menu)) startUp
tz@506
   301
    "
tz@506
   302
tz@506
   303
    <resource: #menu>
tz@506
   304
tz@506
   305
    ^
tz@506
   306
     
tz@506
   307
       #(#Menu
tz@506
   308
          
tz@506
   309
           #(
tz@506
   310
             #(#MenuItem
tz@731
   311
                #label: 'File'
tz@731
   312
                #submenu: 
tz@506
   313
                 #(#Menu
tz@506
   314
                    
tz@506
   315
                     #(
tz@506
   316
                       #(#MenuItem
tz@731
   317
                          #label: 'New'
tz@731
   318
                          #value: #doNew
tz@731
   319
                          #activeHelpKey: #fileNew
tz@506
   320
                      )
tz@506
   321
                       #(#MenuItem
tz@731
   322
                          #label: '-'
tz@522
   323
                      )
tz@522
   324
                       #(#MenuItem
tz@731
   325
                          #label: 'Load...'
tz@731
   326
                          #translateLabel: true
tz@731
   327
                          #value: #doLoad
tz@731
   328
                          #activeHelpKey: #fileLoad
tz@506
   329
                      )
tz@506
   330
                       #(#MenuItem
tz@731
   331
                          #label: '-'
tz@506
   332
                      )
tz@506
   333
                       #(#MenuItem
tz@731
   334
                          #label: 'Save'
tz@731
   335
                          #value: #doSave
tz@731
   336
                          #activeHelpKey: #fileSave
tz@506
   337
                      )
tz@506
   338
                       #(#MenuItem
tz@731
   339
                          #label: 'Save As...'
tz@731
   340
                          #value: #doSaveAs
tz@731
   341
                          #activeHelpKey: #fileSaveAs
tz@506
   342
                      )
tz@506
   343
                       #(#MenuItem
tz@731
   344
                          #label: '-'
tz@506
   345
                      )
tz@506
   346
                       #(#MenuItem
tz@731
   347
                          #label: 'Browse Class'
tz@731
   348
                          #value: #doBrowseClass
tz@731
   349
                          #activeHelpKey: #fileBrowseClass
tz@731
   350
                          #enabled: #hasValidClass
tz@506
   351
                      )
tz@506
   352
                       #(#MenuItem
tz@731
   353
                          #label: '-'
tz@581
   354
                      )
tz@581
   355
                       #(#MenuItem
tz@731
   356
                          #label: 'Exit'
tz@731
   357
                          #value: #closeRequest
tz@731
   358
                          #activeHelpKey: #fileExit
tz@506
   359
                      )
tz@506
   360
                    ) nil
tz@506
   361
                    nil
tz@506
   362
                )
tz@506
   363
            )
tz@506
   364
             #(#MenuItem
tz@731
   365
                #label: 'Edit'
tz@731
   366
                #submenuChannel: #menuEdit
tz@506
   367
            )
tz@506
   368
             #(#MenuItem
tz@731
   369
                #label: 'Add'
tz@731
   370
                #submenu: 
tz@522
   371
                 #(#Menu
tz@522
   372
                    
tz@522
   373
                     #(
tz@522
   374
                       #(#MenuItem
tz@731
   375
                          #label: 'Child'
tz@731
   376
                          #value: #doCreateChild
tz@731
   377
                          #activeHelpKey: #addChild
tz@731
   378
                          #enabled: #canCreateChildChannel
tz@731
   379
                          #labelImage: #(#ResourceRetriever #HierarchicalListEditor #createChildIcon 'Child')
tz@522
   380
                      )
tz@522
   381
                       #(#MenuItem
tz@731
   382
                          #label: 'Sister'
tz@731
   383
                          #value: #doCreateSister
tz@731
   384
                          #activeHelpKey: #addSister
tz@731
   385
                          #enabled: #canCreateSisterChannel
tz@731
   386
                          #labelImage: #(#ResourceRetriever #HierarchicalListEditor #createSisterIcon 'Sister')
tz@522
   387
                      )
tz@522
   388
                    ) nil
tz@522
   389
                    nil
tz@522
   390
                )
tz@522
   391
            )
tz@522
   392
             #(#MenuItem
tz@747
   393
                #label: 'History'
tz@747
   394
                #submenuChannel: #menuHistory
tz@747
   395
            )
tz@747
   396
             #(#MenuItem
tz@731
   397
                #label: 'Help'
tz@731
   398
                #startGroup: #right
tz@731
   399
                #submenuChannel: #menuHelp
tz@546
   400
            )
tz@506
   401
          ) nil
tz@506
   402
          nil
tz@506
   403
      )
tz@506
   404
!
tz@506
   405
tz@506
   406
menuEdit
tz@736
   407
    "This resource specification was automatically generated
tz@736
   408
     by the MenuEditor of ST/X."
tz@506
   409
tz@736
   410
    "Do not manually edit this!! If it is corrupted,
tz@736
   411
     the MenuEditor may not be able to read the specification."
tz@506
   412
tz@506
   413
    "
tz@506
   414
     MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuEdit
tz@506
   415
     (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuEdit)) startUp
tz@506
   416
    "
tz@506
   417
tz@506
   418
    <resource: #menu>
tz@506
   419
tz@506
   420
    ^
tz@506
   421
     
tz@506
   422
       #(#Menu
tz@506
   423
          
tz@506
   424
           #(
tz@506
   425
             #(#MenuItem
tz@731
   426
                #label: 'Cut'
tz@731
   427
                #value: #doCut
tz@731
   428
                #activeHelpKey: #editCut
tz@731
   429
                #enabled: #valueOfCanCut
tz@506
   430
            )
tz@506
   431
             #(#MenuItem
tz@731
   432
                #label: 'Copy'
tz@731
   433
                #value: #doCopy
tz@731
   434
                #activeHelpKey: #editCopy
tz@731
   435
                #enabled: #valueOfCanCopy
tz@506
   436
            )
tz@506
   437
             #(#MenuItem
tz@731
   438
                #label: 'Paste'
tz@731
   439
                #value: #doPaste
tz@731
   440
                #activeHelpKey: #editPaste
tz@731
   441
                #enabled: #valueOfCanPaste
tz@506
   442
            )
tz@506
   443
             #(#MenuItem
tz@731
   444
                #label: 'Delete'
tz@731
   445
                #value: #doDelete
tz@731
   446
                #activeHelpKey: #editPaste
tz@731
   447
                #enabled: #valueOfCanCut
tz@506
   448
            )
tz@506
   449
             #(#MenuItem
tz@731
   450
                #label: '-'
tz@506
   451
            )
tz@506
   452
             #(#MenuItem
tz@731
   453
                #label: 'Move Up'
tz@731
   454
                #value: #doStepUp
tz@731
   455
                #activeHelpKey: #editMoveUp
tz@731
   456
                #enabled: #canStepOverChannel
tz@882
   457
                #labelImage: #(#ResourceRetriever #Icon #upIcon 'Move Up')
tz@506
   458
            )
tz@506
   459
             #(#MenuItem
tz@731
   460
                #label: 'Move Down'
tz@731
   461
                #value: #doStepDown
tz@731
   462
                #activeHelpKey: #editMoveDown
tz@731
   463
                #enabled: #canStepOverChannel
tz@882
   464
                #labelImage: #(#ResourceRetriever #Icon #downIcon 'Move Down')
tz@506
   465
            )
tz@506
   466
             #(#MenuItem
tz@731
   467
                #label: 'Move In'
tz@731
   468
                #value: #doStepIn
tz@731
   469
                #activeHelpKey: #editMoveIn
tz@731
   470
                #enabled: #canStepInChannel
tz@882
   471
                #labelImage: #(#ResourceRetriever #Icon #downRightIcon 'Move In')
tz@731
   472
            )
tz@731
   473
             #(#MenuItem
tz@731
   474
                #label: 'Move Out'
tz@731
   475
                #value: #doStepOut
tz@731
   476
                #activeHelpKey: #editMoveOut
tz@731
   477
                #enabled: #canStepOutChannel
tz@882
   478
                #labelImage: #(#ResourceRetriever #Icon #leftDownIcon 'Move Out')
tz@506
   479
            )
tz@506
   480
          ) nil
tz@506
   481
          nil
tz@506
   482
      )
tz@506
   483
!
tz@506
   484
tz@506
   485
menuToolbar
tz@736
   486
    "This resource specification was automatically generated
tz@736
   487
     by the MenuEditor of ST/X."
tz@506
   488
tz@736
   489
    "Do not manually edit this!! If it is corrupted,
tz@736
   490
     the MenuEditor may not be able to read the specification."
tz@506
   491
tz@506
   492
    "
tz@506
   493
     MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuToolbar
tz@506
   494
     (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuToolbar)) startUp
tz@506
   495
    "
tz@506
   496
tz@506
   497
    <resource: #menu>
tz@506
   498
tz@506
   499
    ^
tz@506
   500
     
tz@506
   501
       #(#Menu
tz@506
   502
          
tz@506
   503
           #(
tz@506
   504
             #(#MenuItem
tz@731
   505
                #label: 'New'
tz@731
   506
                #isButton: true
tz@731
   507
                #value: #doNew
tz@731
   508
                #activeHelpKey: #fileNew
tz@882
   509
                #labelImage: #(#ResourceRetriever #Icon #newIcon)
tz@506
   510
            )
tz@506
   511
             #(#MenuItem
tz@731
   512
                #label: 'Load'
tz@731
   513
                #isButton: true
tz@731
   514
                #value: #doLoad
tz@731
   515
                #activeHelpKey: #fileLoad
tz@882
   516
                #labelImage: #(#ResourceRetriever #Icon #loadIcon)
tz@506
   517
            )
tz@506
   518
             #(#MenuItem
tz@731
   519
                #label: 'Save'
tz@731
   520
                #isButton: true
tz@731
   521
                #value: #doSave
tz@731
   522
                #activeHelpKey: #fileSave
tz@882
   523
                #labelImage: #(#ResourceRetriever #Icon #saveIcon)
tz@506
   524
            )
tz@506
   525
             #(#MenuItem
tz@731
   526
                #label: ''
tz@506
   527
            )
tz@506
   528
             #(#MenuItem
tz@731
   529
                #label: 'Cut'
tz@731
   530
                #isButton: true
tz@731
   531
                #value: #doCut
tz@731
   532
                #activeHelpKey: #editCut
tz@731
   533
                #enabled: #valueOfCanCut
tz@882
   534
                #labelImage: #(#ResourceRetriever #Icon #cutIcon)
tz@506
   535
            )
tz@506
   536
             #(#MenuItem
tz@731
   537
                #label: 'Copy'
tz@731
   538
                #isButton: true
tz@731
   539
                #value: #doCopy
tz@731
   540
                #activeHelpKey: #editCopy
tz@731
   541
                #enabled: #valueOfCanCopy
tz@882
   542
                #labelImage: #(#ResourceRetriever #Icon #copyIcon)
tz@506
   543
            )
tz@506
   544
             #(#MenuItem
tz@731
   545
                #label: 'Paste'
tz@731
   546
                #isButton: true
tz@731
   547
                #value: #doPaste
tz@731
   548
                #activeHelpKey: #editPaste
tz@731
   549
                #enabled: #valueOfCanPaste
tz@882
   550
                #labelImage: #(#ResourceRetriever #Icon #pasteIcon)
tz@506
   551
            )
tz@506
   552
             #(#MenuItem
tz@731
   553
                #label: 'Delete'
tz@731
   554
                #isButton: true
tz@731
   555
                #value: #doDelete
tz@731
   556
                #activeHelpKey: #editDelete
tz@731
   557
                #enabled: #valueOfCanCut
tz@882
   558
                #labelImage: #(#ResourceRetriever #Icon #deleteIcon)
tz@506
   559
            )
tz@506
   560
             #(#MenuItem
tz@731
   561
                #label: ''
tz@506
   562
            )
tz@506
   563
             #(#MenuItem
tz@731
   564
                #label: 'Add Child'
tz@731
   565
                #isButton: true
tz@731
   566
                #value: #doCreateChild
tz@731
   567
                #activeHelpKey: #addChild
tz@731
   568
                #enabled: #canCreateChildChannel
tz@731
   569
                #labelImage: #(#ResourceRetriever nil #createChildIcon)
tz@731
   570
            )
tz@731
   571
             #(#MenuItem
tz@731
   572
                #label: 'Add Sister'
tz@731
   573
                #isButton: true
tz@731
   574
                #value: #doCreateSister
tz@731
   575
                #activeHelpKey: #addSister
tz@731
   576
                #enabled: #canCreateSisterChannel
tz@731
   577
                #labelImage: #(#ResourceRetriever nil #createSisterIcon)
tz@731
   578
            )
tz@731
   579
             #(#MenuItem
tz@731
   580
                #label: ''
tz@731
   581
            )
tz@731
   582
             #(#MenuItem
tz@731
   583
                #label: 'Move Up'
tz@731
   584
                #isButton: true
tz@731
   585
                #value: #doStepUp
tz@731
   586
                #activeHelpKey: #editMoveUp
tz@731
   587
                #enabled: #canStepOverChannel
tz@882
   588
                #labelImage: #(#ResourceRetriever #Icon #upIcon)
tz@731
   589
            )
tz@731
   590
             #(#MenuItem
tz@731
   591
                #label: 'Move Down'
tz@731
   592
                #isButton: true
tz@731
   593
                #value: #doStepDown
tz@731
   594
                #activeHelpKey: #editMoveDown
tz@731
   595
                #enabled: #canStepOverChannel
tz@882
   596
                #labelImage: #(#ResourceRetriever #Icon #downIcon)
tz@731
   597
            )
tz@731
   598
             #(#MenuItem
tz@731
   599
                #label: 'Move In'
tz@731
   600
                #isButton: true
tz@731
   601
                #value: #doStepIn
tz@731
   602
                #activeHelpKey: #editMoveIn
tz@731
   603
                #enabled: #canStepInChannel
tz@882
   604
                #labelImage: #(#ResourceRetriever #Icon #downRightIcon)
tz@731
   605
            )
tz@731
   606
             #(#MenuItem
tz@731
   607
                #label: 'Move Out'
tz@731
   608
                #isButton: true
tz@731
   609
                #value: #doStepOut
tz@731
   610
                #activeHelpKey: #editMoveOut
tz@731
   611
                #enabled: #canStepOutChannel
tz@882
   612
                #labelImage: #(#ResourceRetriever #Icon #leftDownIcon)
tz@506
   613
            )
tz@506
   614
          ) nil
tz@506
   615
          nil
tz@506
   616
      )
tz@506
   617
! !
tz@506
   618
ca@300
   619
!HierarchicalListEditor class methodsFor:'printing'!
ca@300
   620
ca@300
   621
prettyPrintArray:anArray on:aStream indent:anIndent
ca@300
   622
    "print a literal array in a nice format
ca@300
   623
    "
ca@300
   624
    |arg sol|
ca@300
   625
ca@300
   626
    sol := aStream position.
ca@300
   627
    aStream spaces:anIndent.
ca@300
   628
    aStream nextPutAll:'#('.
ca@300
   629
ca@300
   630
    anArray first isSymbol ifTrue:[
ca@300
   631
        arg := anArray first.
ca@300
   632
        aStream nextPut:$#.
ca@300
   633
        aStream nextPutAll:anArray first.
ca@300
   634
        aStream cr.
ca@300
   635
        anArray size == 2 ifTrue:[
ca@300
   636
            self prettyPrintArray:(anArray last)
ca@300
   637
                               on:aStream
ca@300
   638
                           indent:(anIndent + 4).
ca@300
   639
        ].
ca@300
   640
        aStream spaces:anIndent.
ca@300
   641
        aStream nextPut:$).
ca@300
   642
      ^ self  
ca@300
   643
    ].
ca@300
   644
ca@300
   645
    aStream nextPut:$'.
ca@300
   646
    aStream nextPutAll:(anArray at:1).
ca@300
   647
    aStream nextPut:$'.
ca@300
   648
    arg := anArray at:2 ifAbsent:nil.
ca@300
   649
ca@300
   650
    arg isString ifTrue:[
ca@300
   651
        aStream spaces:((50 - (aStream position - sol)) max:4).
ca@300
   652
ca@300
   653
        arg isSymbol ifTrue:[
ca@300
   654
            aStream nextPut:$#.
ca@300
   655
        ].
ca@300
   656
        aStream nextPut:$'.
ca@300
   657
        aStream nextPutAll:arg.
ca@300
   658
        aStream nextPut:$'.
ca@300
   659
        arg := anArray at:3 ifAbsent:nil.
ca@300
   660
    ].
ca@300
   661
    arg isArray ifTrue:[
ca@300
   662
        aStream nextPutAll:' #('.
ca@300
   663
        aStream cr.
ca@300
   664
        arg do:[:e|self prettyPrintArray:e on:aStream indent:(anIndent + 4)].
ca@300
   665
        aStream spaces:anIndent.
ca@300
   666
        aStream nextPut:$).
ca@300
   667
    ].
ca@300
   668
    aStream nextPut:$).
ca@300
   669
    aStream cr.
ca@300
   670
! !
ca@300
   671
ca@300
   672
!HierarchicalListEditor methodsFor:'aspects'!
ca@300
   673
ca@300
   674
canCreateChildChannel
ca@300
   675
tz@423
   676
    ^builder booleanValueAspectFor:#canCreateChildChannel
ca@300
   677
ca@300
   678
!
ca@300
   679
ca@300
   680
canCreateSisterChannel
ca@300
   681
tz@423
   682
    ^builder booleanValueAspectFor:#canCreateSisterChannel
ca@300
   683
ca@300
   684
!
ca@300
   685
ca@300
   686
canStepInChannel
ca@300
   687
tz@423
   688
    ^builder booleanValueAspectFor:#canStepInChannel
ca@300
   689
ca@300
   690
!
ca@300
   691
ca@300
   692
canStepOutChannel
ca@300
   693
tz@423
   694
    ^builder booleanValueAspectFor:#canStepOutChannel
ca@300
   695
ca@300
   696
!
ca@300
   697
ca@300
   698
canStepOverChannel
ca@300
   699
tz@423
   700
    ^builder booleanValueAspectFor:#canStepOverChannel
ca@300
   701
ca@300
   702
!
ca@300
   703
ca@300
   704
itemName
ca@300
   705
ca@300
   706
    |holder|
ca@300
   707
ca@300
   708
    (holder := builder bindingAt:#itemName) isNil ifTrue:[
ca@300
   709
        builder aspectAt:#itemName put:(holder :=  ValueHolder new).
ca@300
   710
        holder addDependent:self.
ca@300
   711
    ].
ca@300
   712
    ^ holder
ca@300
   713
!
ca@300
   714
ca@300
   715
itemValue
ca@300
   716
ca@300
   717
    |holder|
ca@300
   718
ca@300
   719
    (holder := builder bindingAt:#itemValue) isNil ifTrue:[
ca@300
   720
        builder aspectAt:#itemValue put:(holder :=  ValueHolder new).
ca@300
   721
        holder addDependent:self.
ca@300
   722
    ].
ca@300
   723
    ^ holder
ca@300
   724
!
ca@300
   725
ca@300
   726
treeView
ca@300
   727
tz@423
   728
    ^treeView
ca@300
   729
! !
ca@300
   730
tz@731
   731
!HierarchicalListEditor methodsFor:'building'!
ca@300
   732
tz@731
   733
buildFromClass:aClass andSelector:aSelector
tz@731
   734
    "rebuild window from a class and selector"
tz@423
   735
tz@731
   736
    |cls sel anchor|
ca@300
   737
tz@731
   738
    cls := self resolveName:aClass.
tz@731
   739
    specSelector := nil.
tz@581
   740
tz@731
   741
    aSelector size ~~ 0 
tz@731
   742
    ifTrue:
tz@731
   743
    [
tz@731
   744
        sel := aSelector asString withoutSeparators.
tz@731
   745
        sel size ~~ 0 ifTrue:[specSelector := sel asSymbol]
tz@731
   746
    ].
tz@731
   747
    treeView selection:nil.
tz@581
   748
tz@731
   749
    (specSelector notNil and:[cls notNil]) 
tz@731
   750
    ifTrue:
tz@731
   751
    [
tz@731
   752
        (cls respondsTo:specSelector) 
tz@731
   753
        ifTrue:
tz@731
   754
        [
tz@731
   755
            anchor := cls perform:specSelector.
tz@731
   756
            anchor isArray ifTrue:[anchor := anchor decodeAsLiteralArray]
tz@731
   757
        ].
tz@731
   758
    ].              
tz@731
   759
    anchor notNil     
tz@731
   760
        ifTrue:  [anchor expand. treeView root:anchor] 
tz@731
   761
        ifFalse: [treeView root isNil ifTrue: [self buildRoot]].
tz@581
   762
tz@731
   763
    treeView selection: 1.
tz@731
   764
tz@731
   765
    self updateHistory.
tz@731
   766
    self updateInfoLabel.
tz@731
   767
tz@731
   768
tz@731
   769
tz@731
   770
!
tz@731
   771
tz@736
   772
buildFromResourceSpec: aListSpec
tz@731
   773
tz@731
   774
    treeView root: aListSpec
tz@731
   775
tz@731
   776
!
tz@731
   777
tz@731
   778
buildRoot
tz@731
   779
    "build just a root"
tz@731
   780
tz@731
   781
    treeView root:(TreeItem name:'Root' contents:#Anchor).
tz@731
   782
    treeView selection:1.
tz@581
   783
! !
tz@581
   784
ca@1575
   785
!HierarchicalListEditor methodsFor:'menu accessing'!
ca@1575
   786
ca@1575
   787
menu
ca@1575
   788
    ^ self class menu
ca@1575
   789
!
ca@1575
   790
ca@1575
   791
menuEdit
ca@1575
   792
    ^ self class menuEdit
ca@1575
   793
!
ca@1575
   794
ca@1575
   795
menuToolbar
ca@1575
   796
    ^ self class menuToolbar
ca@1575
   797
! !
ca@1575
   798
tz@423
   799
!HierarchicalListEditor methodsFor:'private'!
tz@423
   800
tz@731
   801
getDepthAndSistersNumberOfNode: aNode onParentNode: aParentNode
tz@731
   802
    "return depth of selected node"
tz@423
   803
tz@731
   804
    |parent childNode depthAndSistersNumbers str|
tz@731
   805
tz@731
   806
    depthAndSistersNumbers := OrderedCollection new.
tz@731
   807
    childNode := aNode.
tz@731
   808
    parent := aParentNode.
tz@731
   809
    [parent notNil] 
tz@731
   810
    whileTrue: 
tz@423
   811
    [
tz@731
   812
        depthAndSistersNumbers add: (parent children indexOf: childNode). 
tz@731
   813
        childNode := parent. 
tz@731
   814
        parent := parent parent. 
tz@423
   815
    ].
tz@731
   816
    depthAndSistersNumbers removeFirst; addFirst: aParentNode children size.
tz@731
   817
    str := ''.
tz@731
   818
    depthAndSistersNumbers reverseDo: [:n| str := str, n printString, '.'].
tz@731
   819
    ^str copyFrom: 1 to: str size - 1
tz@506
   820
!
tz@506
   821
tz@423
   822
newItem
tz@423
   823
    "creates and returns a new default item"
tz@423
   824
tz@558
   825
    ^TreeItem name: 'Item' contents: nil
tz@423
   826
!
tz@423
   827
tz@423
   828
updateChannels
tz@423
   829
    "update channels"
tz@423
   830
tz@423
   831
    |node parent chnStepIn chnStepOut chnStepOvr chnChild chnSister|
tz@423
   832
tz@423
   833
    chnStepIn := chnStepOut := chnStepOvr := chnChild := chnSister := false.
tz@423
   834
tz@423
   835
    (node := treeView selectedNode) notNil 
tz@423
   836
    ifTrue:
tz@423
   837
    [
tz@731
   838
        (builder componentAt: #SpecView) beVisible.
tz@423
   839
        chnChild := true.
tz@423
   840
        (parent := node parent) notNil 
tz@423
   841
        ifTrue:
tz@423
   842
        [
tz@423
   843
            chnSister  := true.
tz@423
   844
            chnStepOvr := parent numberOfChildren > 1.
tz@423
   845
            chnStepOut := parent parent notNil.
tz@423
   846
            chnStepIn  := node ~~ parent lastChild
tz@423
   847
        ]
tz@423
   848
    ]
tz@423
   849
    ifFalse:
tz@423
   850
    [
tz@731
   851
        (builder componentAt: #SpecView) beInvisible
tz@423
   852
    ].
tz@423
   853
    self canCreateChildChannel  value:chnChild.
tz@423
   854
    self canCreateSisterChannel value:chnSister.
tz@423
   855
    self canStepOverChannel     value:chnStepOvr.
tz@423
   856
    self canStepOutChannel      value:chnStepOut.
tz@506
   857
    self canStepInChannel       value:chnStepIn.
tz@506
   858
tz@731
   859
    self valueOfCanCut value: (treeView selection notNil      
tz@731
   860
        ifTrue:[(treeView isInSelection:1) not] 
tz@731
   861
        ifFalse: [false]).
tz@506
   862
tz@731
   863
    self valueOfCanCopy value: self valueOfCanCut value.
tz@731
   864
tz@736
   865
    self valueOfCanPaste value: treeView selectedNode notNil & self valueOfCanPaste value.
tz@423
   866
!
tz@423
   867
tz@423
   868
updateInputFields
tz@423
   869
    "reload item value into input fields"
tz@423
   870
tz@423
   871
    |node|
tz@423
   872
tz@423
   873
    (node := treeView selectedNode) notNil 
tz@423
   874
    ifTrue:
tz@423
   875
    [
tz@423
   876
        self itemName  value:node name.
tz@423
   877
        self itemValue value:node contents
tz@423
   878
    ] 
tz@423
   879
    ifFalse:
tz@423
   880
    [
tz@423
   881
        self itemName  value:''.
tz@423
   882
        self itemValue value:nil
tz@423
   883
    ].
tz@423
   884
    self valueOfEnablingCommitButtons value: false
tz@423
   885
! !
tz@423
   886
mawalch@3306
   887
!HierarchicalListEditor methodsFor:'startup & release'!
tz@423
   888
tz@423
   889
initialize
tz@423
   890
    "setup default values"
tz@423
   891
tz@423
   892
    super initialize.
tz@423
   893
tz@423
   894
    treeView := SelectionInTreeView new.
tz@423
   895
    treeView multipleSelectOk: true.
tz@423
   896
    treeView showDirectoryIndicator: true.
tz@423
   897
    treeView showDirectoryIndicatorForRoot: false.
tz@423
   898
    treeView action:[:aNr| self updateChannels. self updateInputFields].
tz@731
   899
    treeView selectConditionBlock: [:i|self askForItemModification].
tz@423
   900
    treeView validateDoubleClickBlock: [:node| node ~~ treeView model list first].
tz@423
   901
!
tz@423
   902
tz@731
   903
openModalOnTreeItem: aTreeItem
tz@731
   904
    "build a tree from aTreeItem and open it modal"
tz@423
   905
tz@736
   906
    super openModalOnResourceSpec: aTreeItem
tz@423
   907
! !
tz@423
   908
tz@423
   909
!HierarchicalListEditor methodsFor:'user actions'!
tz@423
   910
tz@423
   911
accept
tz@423
   912
    "invoked by button 'OK'"
tz@423
   913
tz@423
   914
    |node index|
tz@423
   915
tz@423
   916
    (index := treeView selectedIndex) ~~ 0 
tz@423
   917
    ifTrue:
tz@423
   918
    [
tz@423
   919
        node := treeView nodeAtIndex:index.
tz@423
   920
        node name: self itemName value.
tz@423
   921
        node contents: self itemValue value.
tz@423
   922
        treeView redrawLine:index.
tz@423
   923
    ].
tz@731
   924
    modified := true.
tz@423
   925
    self valueOfEnablingCommitButtons value: false
tz@423
   926
!
tz@423
   927
tz@423
   928
cancel
tz@423
   929
    "invoked by button 'Cancel'"
tz@423
   930
tz@423
   931
    self updateInputFields.
tz@423
   932
tz@731
   933
    modified := false.
tz@423
   934
    self valueOfEnablingCommitButtons value: false
tz@423
   935
!
tz@423
   936
tz@423
   937
doCopy
tz@423
   938
    "copy current selected nodes into copy buffer"
tz@423
   939
tz@731
   940
    self class clipboard: OrderedCollection new.
tz@736
   941
    treeView selectedNodesDo:[:aNode| self class clipboard add: aNode copy].
tz@747
   942
    self updateAllToolInstances
tz@423
   943
!
ca@300
   944
ca@300
   945
doCreateChild
tz@423
   946
    "create a child within selected parent"
tz@423
   947
tz@558
   948
    |node newItem|
ca@300
   949
tz@731
   950
    ((node := treeView selectedNode) notNil and: [self askForItemModification])
tz@423
   951
    ifTrue:
tz@423
   952
    [
tz@558
   953
        treeView model add: (newItem := self newItem) afterIndex: node children size below:node.
tz@558
   954
        newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node).
ca@300
   955
        treeView selectedNodeExpand:true.
tz@558
   956
        treeView selectNode: newItem.
ca@300
   957
        self updateChannels.
tz@731
   958
        modified := true
tz@423
   959
    ]
ca@300
   960
!
ca@300
   961
ca@300
   962
doCreateSister
ca@300
   963
    "create a sister next to selected item
ca@300
   964
    "
tz@558
   965
    |node newItem|
ca@300
   966
tz@731
   967
    ((node := treeView selectedNode) notNil and: [self askForItemModification]) 
tz@423
   968
    ifTrue:
tz@423
   969
    [
tz@558
   970
        newItem := self newItem.
tz@423
   971
        node parent notNil 
tz@562
   972
            ifTrue: [treeView model add: newItem after:node] 
tz@558
   973
            ifFalse:[treeView model add: newItem beforeIndex:1 below:node].
tz@562
   974
tz@558
   975
        newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node parent).
tz@558
   976
        treeView selectNode: newItem.
tz@506
   977
        self updateChannels.
tz@731
   978
        modified := true
tz@423
   979
    ]
ca@300
   980
!
ca@300
   981
tz@423
   982
doCut
tz@423
   983
    "cut current selected nodes"
ca@300
   984
tz@423
   985
    |selection|
tz@731
   986
    (treeView hasSelection and: [self askForItemModification]) 
tz@423
   987
    ifTrue:
tz@423
   988
    [
tz@423
   989
        self doCopy.
tz@423
   990
        selection := treeView selection asSortedCollection.
tz@423
   991
        treeView selectedNodesRemove.
tz@423
   992
        treeView selection: selection first - 1.
tz@747
   993
        self updateAllToolInstances.
tz@731
   994
        modified := true
ca@300
   995
    ]
ca@300
   996
!
ca@300
   997
tz@731
   998
doDelete
tz@731
   999
    "delete current selected nodes"
tz@423
  1000
tz@731
  1001
    |selection|
tz@731
  1002
    (treeView hasSelection and: [self askForItemModification]) 
tz@731
  1003
    ifTrue:
tz@731
  1004
    [
tz@731
  1005
        selection := treeView selection asSortedCollection.
tz@731
  1006
        treeView selectedNodesRemove.
tz@731
  1007
        treeView selection: selection first - 1.
tz@731
  1008
        self updateChannels.
tz@731
  1009
        modified := true
tz@731
  1010
    ]
tz@731
  1011
!
ca@300
  1012
tz@731
  1013
doNew
tz@736
  1014
    "first do super new; then make a build 
tz@736
  1015
     of a resource spec containing a root"
ca@300
  1016
tz@736
  1017
    super doNew ifTrue: [self buildRoot]
ca@300
  1018
ca@300
  1019
ca@300
  1020
ca@300
  1021
!
ca@300
  1022
tz@731
  1023
doPaste
tz@731
  1024
    "paste after current selected item"
tz@731
  1025
tz@736
  1026
    (self askForItemModification and: [self class clipboard notNil])
tz@731
  1027
    ifTrue:
tz@731
  1028
    [
tz@731
  1029
        |copiedNode|
tz@731
  1030
        self class clipboard do:
tz@731
  1031
        [:node|
tz@731
  1032
            copiedNode := node copy.
tz@731
  1033
            treeView selectedNodeAdd: copiedNode. 
tz@731
  1034
            treeView selectNode: copiedNode.
tz@731
  1035
        ].
tz@731
  1036
        self updateChannels.
tz@731
  1037
        modified := true
tz@731
  1038
    ]
tz@731
  1039
!
tz@731
  1040
tz@731
  1041
doReload
tz@731
  1042
    "reload spec from current class and selector"
tz@731
  1043
tz@731
  1044
    self buildFrom:specClass andSelector:specSelector
tz@731
  1045
tz@731
  1046
!
tz@731
  1047
tz@731
  1048
doSave
tz@423
  1049
    "install code"
tz@423
  1050
tz@731
  1051
    |cls code spec category mthd stream|
ca@300
  1052
tz@423
  1053
    (specClass notNil and:[specSelector notNil])
tz@423
  1054
    ifFalse:
tz@423
  1055
    [
tz@731
  1056
        ^self doSaveAs
ca@300
  1057
    ].
ca@300
  1058
tz@731
  1059
    cls := self resolveName: specClass.
ca@300
  1060
    spec   := (treeView nodeAtIndex:1) literalArrayEncoding.
ca@300
  1061
    stream := WriteStream on:String new.
ca@300
  1062
    self class prettyPrintArray:spec on:stream indent:4.
ca@300
  1063
    spec       := stream contents.
tz@731
  1064
    category   := 'list specs'.
ca@300
  1065
tz@731
  1066
    (mthd := cls class compiledMethodAt:specSelector) notNil 
tz@423
  1067
    ifTrue:
tz@423
  1068
    [
tz@423
  1069
        category := mthd category
ca@300
  1070
    ].
ca@300
  1071
ca@300
  1072
    code := Character excla asString 
tz@731
  1073
            , cls name , ' class methodsFor:' , category storeString
ca@300
  1074
            , Character excla asString , '\\'
ca@300
  1075
ca@300
  1076
            , specSelector , '\'
tz@736
  1077
            , (self class codeGenerationComment replChar:$!! withString:'!!!!')
tz@736
  1078
            , '\\    "\'
tz@731
  1079
            , '     HierarchicalListEditor openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
ca@300
  1080
            , '    "\'.
ca@300
  1081
ca@300
  1082
    code := code 
ca@300
  1083
            , '\'
ca@300
  1084
            , '    <resource: #hierarchicalList>\\'
ca@300
  1085
            , '    ^\' 
ca@300
  1086
            , spec
ca@300
  1087
            , ' decodeAsLiteralArray\'
ca@300
  1088
            , Character excla asString
ca@300
  1089
            , ' '
ca@300
  1090
            , Character excla asString
ca@300
  1091
            , '\\'.
ca@300
  1092
ca@300
  1093
    code := code withCRs.
ca@300
  1094
    (ReadStream on:code) fileIn.
ca@300
  1095
tz@731
  1096
    self updateHistory.
tz@731
  1097
    hasSaved := true.
tz@731
  1098
    modified := false.
ca@300
  1099
!
ca@300
  1100
tz@423
  1101
doStepDown
tz@423
  1102
    "move selected item after next item"
ca@300
  1103
tz@423
  1104
    treeView selectedNodeChangeSequenceOrder:1.
tz@506
  1105
    self updateChannels.
tz@731
  1106
    modified := true
tz@506
  1107
ca@300
  1108
!
ca@300
  1109
tz@423
  1110
doStepIn
tz@423
  1111
    "lets become the selected item a child of its next sister"
tz@423
  1112
tz@423
  1113
    treeView selectedNodeBecomeChildOfNext.
tz@506
  1114
    self updateChannels.
tz@731
  1115
    modified := true
tz@506
  1116
tz@506
  1117
tz@506
  1118
ca@300
  1119
!
ca@300
  1120
tz@423
  1121
doStepOut
tz@423
  1122
    "let selected node become a sister of its current parent"
tz@423
  1123
tz@423
  1124
    treeView selectedNodeBecomeSisterOfParent.
tz@506
  1125
    self updateChannels.
tz@731
  1126
    modified := true
tz@506
  1127
tz@506
  1128
tz@506
  1129
ca@300
  1130
!
ca@300
  1131
tz@423
  1132
doStepUp
tz@423
  1133
    "move selected item before previous item"
ca@300
  1134
tz@423
  1135
    treeView selectedNodeChangeSequenceOrder:-1.
tz@506
  1136
    self updateChannels.
tz@731
  1137
    modified := true
tz@506
  1138
tz@506
  1139
tz@506
  1140
cg@1856
  1141
!
cg@1856
  1142
cg@1856
  1143
openDocumentation
cg@1856
  1144
   self openHTMLDocument:'tools/uipainter/HierarchicalListEditor.html'.
ca@300
  1145
! !
ca@300
  1146
ca@300
  1147
!HierarchicalListEditor class methodsFor:'documentation'!
ca@300
  1148
ca@300
  1149
version
ca@300
  1150
    ^ '$Header$'
ca@300
  1151
! !
mawalch@3306
  1152