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