HierarchicalListEditor.st
changeset 731 cd36a0c9ba62
parent 602 5bf03bf611c8
child 736 6db5efc5df90
equal deleted inserted replaced
730:238d796c5da0 731:cd36a0c9ba62
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 
    14 
    15 
    15 
    16 ToolApplicationModel subclass:#HierarchicalListEditor
    16 ListSpecEditor subclass:#HierarchicalListEditor
    17 	instanceVariableNames:'isModified didInstall treeView specClass specSelector'
    17 	instanceVariableNames:'treeView'
    18 	classVariableNames:'CopyBuffer'
    18 	classVariableNames:''
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    21 !
    21 !
    22 
    22 
    23 !HierarchicalListEditor class methodsFor:'documentation'!
    23 !HierarchicalListEditor class methodsFor:'documentation'!
    39 
    39 
    40 !
    40 !
    41 
    41 
    42 documentation
    42 documentation
    43 "
    43 "
    44     HierarchicalListEditor is used by the UIPainter to
    44     The HierarchicalListEditor allows you to create, modify or just inspect
    45     create or maintain a hierarchical list.
    45     (statical) hierarchical lists for the SelectionInListView.
    46 
    46 
    47     [start with:]
    47     [start with:]
    48         HierarchicalListEditor open
    48         HierarchicalListEditor open
    49 
    49 
    50     [see also:]
    50     [see also:]
    51         UIPainter
    51         UIPainter
    52 
    52 
    53     [author:]
    53     [author:]
    54         Claus Atzkern, eXept Software AG
    54         Claus Atzkern, eXept Software AG
       
    55         Thomas Zwick, eXept Software AG
    55 "
    56 "
    56 
    57 
    57 
    58 
       
    59 
       
    60 ! !
       
    61 
       
    62 !HierarchicalListEditor class methodsFor:'instance creation'!
       
    63 
       
    64 openModalOnTreeItem: aTreeItem
       
    65     "Open a HierarchicalListEditor modal on aTreeItem"
       
    66     "self openModalOnTreeItem: (TreeItem name: 'Label' contents: #Contents)"
       
    67 
       
    68     ^self new openModalOnTreeItem: aTreeItem
       
    69 
       
    70 ! !
       
    71 
       
    72 !HierarchicalListEditor class methodsFor:'accessing'!
       
    73 
       
    74 resourceType
       
    75     "get the type of resource of the method generated by the HierarchicalListEditor"
       
    76 
       
    77     ^#hierarchicalList
    58 
    78 
    59 ! !
    79 ! !
    60 
    80 
    61 !HierarchicalListEditor class methodsFor:'help specs'!
    81 !HierarchicalListEditor class methodsFor:'help specs'!
    62 
    82 
    77 'Adds a new sister item.'
    97 'Adds a new sister item.'
    78 
    98 
    79 #contents
    99 #contents
    80 'Contents of the tree item.'
   100 'Contents of the tree item.'
    81 
   101 
       
   102 #fileLoad
       
   103 'Opens a dialog for selecting and loading a hierarchical list spec from a class.'
       
   104 
    82 #fileNew
   105 #fileNew
    83 'Creates a new hierarchical list.'
   106 'Creates a new hierarchical list.'
    84 
   107 
    85 #fileReload
       
    86 'Reload hierarchical list from current class and selector.'
       
    87 
       
    88 #fileSave
   108 #fileSave
    89 'Saves current hierarchical list.'
   109 'Saves current hierarchical list spec.'
       
   110 
       
   111 #fileSaveAs
       
   112 'Opens a dialog to save current hierarchical list spec.'
    90 
   113 
    91 #label
   114 #label
    92 'Label of the tree item.'
   115 'Label of the tree item.'
    93 
   116 
    94 )
   117 )
    95 ! !
   118 ! !
    96 
   119 
       
   120 !HierarchicalListEditor class methodsFor:'image specs'!
       
   121 
       
   122 createChildIcon
       
   123     "Generated by the Image Editor"
       
   124     "
       
   125     ImageEditor openOnClass:self andSelector:#createChildIcon
       
   126     "
       
   127 
       
   128     <resource: #image>
       
   129 
       
   130     ^Icon
       
   131         constantNamed:#'HierarchicalListEditor createChildIcon'
       
   132         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]!
       
   133 
       
   134 createSisterIcon
       
   135     "Generated by the Image Editor"
       
   136     "
       
   137     ImageEditor openOnClass:self andSelector:#createSisterIcon
       
   138     "
       
   139 
       
   140     <resource: #image>
       
   141 
       
   142     ^Icon
       
   143         constantNamed:#'HierarchicalListEditor createSisterIcon'
       
   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<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]! !
       
   145 
    97 !HierarchicalListEditor class methodsFor:'interface specs'!
   146 !HierarchicalListEditor class methodsFor:'interface specs'!
    98 
   147 
    99 classAndMethodSpec
   148 windowSpec
   100     "this window spec was automatically generated by the ST/X UIPainter"
   149     "this window spec was automatically generated by the ST/X UIPainter"
   101 
   150 
   102     "do not manually edit this - the painter/builder may not be able to
   151     "do not manually edit this - the painter/builder may not be able to
   103      handle the specification if its corrupted."
   152      handle the specification if its corrupted."
   104 
   153 
   105     "
   154     "
   106      UIPainter new openOnClass:HierarchicalListEditor andSelector:#classAndMethodSpec
   155      UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec
   107      HierarchicalListEditor new openInterface:#classAndMethodSpec
   156      HierarchicalListEditor new openInterface:#windowSpec
   108     "
   157     "
       
   158     "HierarchicalListEditor open"
   109 
   159 
   110     <resource: #canvas>
   160     <resource: #canvas>
   111 
   161 
   112     ^
   162     ^
   113      
   163      
   114        #(#FullSpec
   164        #(#FullSpec
   115           #'window:' 
   165           #window: 
   116            #(#WindowSpec
   166            #(#WindowSpec
   117               #'name:' 'Hierarchical List Editor'
   167               #name: 'Hierarchical List Editor'
   118               #'layout:' #(#LayoutFrame 213 0 373 0 513 0 501 0)
   168               #layout: #(#LayoutFrame 140 0 249 0 614 0 561 0)
   119               #'label:' 'Hierarchical List Editor'
   169               #label: 'Hierarchical List Editor'
   120               #'min:' #(#Point 10 10)
   170               #min: #(#Point 10 10)
   121               #'max:' #(#Point 1160 870)
   171               #max: #(#Point 1160 870)
   122               #'bounds:' #(#Rectangle 213 373 514 502)
   172               #bounds: #(#Rectangle 140 249 615 562)
   123               #'usePreferredExtent:' false
   173               #menu: #menu
       
   174               #usePreferredExtent: false
   124           )
   175           )
   125           #'component:' 
   176           #component: 
   126            #(#SpecCollection
   177            #(#SpecCollection
   127               #'collection:' 
   178               #collection: 
   128                #(
       
   129                  #(#FramedBoxSpec
       
   130                     #'name:' 'framedBox1'
       
   131                     #'layout:' #(#LayoutFrame 0 0.0 3 0.0 0 1.0 -33 1.0)
       
   132                     #'label:' 'Class and selector for code'
       
   133                     #'labelPosition:' #topLeft
       
   134                 )
       
   135                  #(#LabelSpec
       
   136                     #'name:' 'classLabel'
       
   137                     #'layout:' #(#AlignmentOrigin 53 0.11 39 0 1 0.5)
       
   138                     #'label:' 'Class:'
       
   139                     #'adjust:' #right
       
   140                     #'resizeForLabel:' true
       
   141                 )
       
   142                  #(#InputFieldSpec
       
   143                     #'name:' 'classField'
       
   144                     #'layout:' #(#LayoutFrame 57 0.11 27 0 -19 1.0 49 0)
       
   145                     #'enableChannel:' #canChangeClassName
       
   146                     #'tabable:' true
       
   147                     #'model:' #specClassChannel
       
   148                 )
       
   149                  #(#LabelSpec
       
   150                     #'name:' 'methodLabel'
       
   151                     #'layout:' #(#AlignmentOrigin 53 0.11 64 0 1 0.5)
       
   152                     #'label:' 'Selector:'
       
   153                     #'adjust:' #right
       
   154                     #'resizeForLabel:' true
       
   155                 )
       
   156                  #(#InputFieldSpec
       
   157                     #'name:' 'methodField'
       
   158                     #'layout:' #(#LayoutFrame 57 0.11 52 0 -19 1.0 74 0)
       
   159                     #'tabable:' true
       
   160                     #'model:' #specSelectorChannel
       
   161                     #'type:' #string
       
   162                 )
       
   163                  #(#UISubSpecification
       
   164                     #'name:' 'SubSpecification'
       
   165                     #'layout:' #(#LayoutFrame 0 0.0 -29 1 0 1.0 -5 1.0)
       
   166                     #'majorKey:' #ToolApplicationModel
       
   167                     #'minorKey:' #windowSpecForCommitWithoutChannels
       
   168                 )
       
   169               )
       
   170           )
       
   171       )
       
   172 !
       
   173 
       
   174 windowSpec
       
   175     "this window spec was automatically generated by the ST/X UIPainter"
       
   176 
       
   177     "do not manually edit this - the painter/builder may not be able to
       
   178      handle the specification if its corrupted."
       
   179 
       
   180     "
       
   181      UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec
       
   182      HierarchicalListEditor new openInterface:#windowSpec
       
   183     "
       
   184     "HierarchicalListEditor open"
       
   185 
       
   186     <resource: #canvas>
       
   187 
       
   188     ^
       
   189      
       
   190        #(#FullSpec
       
   191           #'window:' 
       
   192            #(#WindowSpec
       
   193               #'name:' 'Hierarchical List Editor'
       
   194               #'layout:' #(#LayoutFrame 92 0 328 0 566 0 640 0)
       
   195               #'label:' 'Hierarchical List Editor'
       
   196               #'min:' #(#Point 10 10)
       
   197               #'max:' #(#Point 1160 870)
       
   198               #'bounds:' #(#Rectangle 92 328 567 641)
       
   199               #'menu:' #menu
       
   200               #'usePreferredExtent:' false
       
   201           )
       
   202           #'component:' 
       
   203            #(#SpecCollection
       
   204               #'collection:' 
       
   205                #(
   179                #(
   206                  #(#MenuPanelSpec
   180                  #(#MenuPanelSpec
   207                     #'name:' 'menuToolbarView'
   181                     #name: 'menuToolbarView'
   208                     #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 32 0)
   182                     #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 32 0)
   209                     #'menu:' #menuToolbar
   183                     #menu: #menuToolbar
   210                 )
   184                 )
   211                  #(#VariableHorizontalPanelSpec
   185                  #(#VariableHorizontalPanelSpec
   212                     #'name:' 'variableHorizontalPanel'
   186                     #name: 'VariableHorizontalPanel'
   213                     #'layout:' #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
   187                     #layout: #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
   214                     #'component:' 
   188                     #component: 
   215                      #(#SpecCollection
   189                      #(#SpecCollection
   216                         #'collection:' 
   190                         #collection: 
   217                          #(
   191                          #(
   218                            #(#ArbitraryComponentSpec
   192                            #(#ArbitraryComponentSpec
   219                               #'name:' 'treeView'
   193                               #name: 'TreeView'
   220                               #'menu:' #menuEdit
   194                               #menu: #menuEdit
   221                               #'hasHorizontalScrollBar:' true
   195                               #hasHorizontalScrollBar: true
   222                               #'hasVerticalScrollBar:' true
   196                               #hasVerticalScrollBar: true
   223                               #'miniScrollerHorizontal:' true
   197                               #miniScrollerHorizontal: true
   224                               #'miniScrollerVertical:' true
   198                               #miniScrollerVertical: true
   225                               #'component:' #treeView
   199                               #component: #treeView
   226                               #'hasBorder:' false
   200                               #hasBorder: false
   227                           )
   201                           )
   228                            #(#ViewSpec
   202                            #(#ViewSpec
   229                               #'name:' 'specView'
   203                               #name: 'SpecView'
   230                               #'component:' 
   204                               #component: 
   231                                #(#SpecCollection
   205                                #(#SpecCollection
   232                                   #'collection:' 
   206                                   #collection: 
   233                                    #(
   207                                    #(
   234                                      #(#LabelSpec
   208                                      #(#LabelSpec
   235                                         #'name:' 'nameLabel'
   209                                         #name: 'nameLabel'
   236                                         #'layout:' #(#AlignmentOrigin 107 0 25 0 1 0.5)
   210                                         #layout: #(#AlignmentOrigin 108 0 26 0 1 0.5)
   237                                         #'label:' 'Label:'
   211                                         #label: 'Label:'
   238                                         #'resizeForLabel:' true
   212                                         #resizeForLabel: true
   239                                     )
   213                                     )
   240                                      #(#InputFieldSpec
   214                                      #(#InputFieldSpec
   241                                         #'name:' 'labelInputField'
   215                                         #name: 'labelInputField'
   242                                         #'layout:' #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
   216                                         #layout: #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
   243                                         #'activeHelpKey:' #label
   217                                         #activeHelpKey: #label
   244                                         #'tabable:' true
   218                                         #tabable: true
   245                                         #'model:' #itemName
   219                                         #model: #itemName
   246                                     )
   220                                     )
   247                                      #(#LabelSpec
   221                                      #(#LabelSpec
   248                                         #'name:' 'valueLabel'
   222                                         #name: 'valueLabel'
   249                                         #'layout:' #(#AlignmentOrigin 107 0 51 0 1 0.5)
   223                                         #layout: #(#AlignmentOrigin 108 0 52 0 1 0.5)
   250                                         #'activeHelpKey:' #contents
   224                                         #activeHelpKey: #contents
   251                                         #'label:' 'Contents:'
   225                                         #label: 'Contents:'
   252                                         #'resizeForLabel:' true
   226                                         #resizeForLabel: true
   253                                     )
   227                                     )
   254                                      #(#InputFieldSpec
   228                                      #(#InputFieldSpec
   255                                         #'name:' 'valueInputField'
   229                                         #name: 'valueInputField'
   256                                         #'layout:' #(#LayoutFrame 110 0 41 0 -5 1.0 63 0)
   230                                         #layout: #(#LayoutFrame 110 0 41 0 -5 1.0 63 0)
   257                                         #'activeHelpKey:' #contents
   231                                         #activeHelpKey: #contents
   258                                         #'tabable:' true
   232                                         #tabable: true
   259                                         #'model:' #itemValue
   233                                         #model: #itemValue
   260                                         #'type:' #symbolOrNil
   234                                         #type: #symbolOrNil
   261                                     )
   235                                     )
   262                                      #(#UISubSpecification
   236                                      #(#UISubSpecification
   263                                         #'name:' 'SubSpecification'
   237                                         #name: 'SubSpecification'
   264                                         #'layout:' #(#LayoutFrame 2 0.0 -26 1.0 -2 1.0 -2 1.0)
   238                                         #layout: #(#LayoutFrame 2 0.0 -26 1.0 -2 1.0 -2 1.0)
   265                                         #'majorKey:' #ToolApplicationModel
   239                                         #majorKey: #ToolApplicationModel
   266                                         #'minorKey:' #windowSpecForCommit
   240                                         #minorKey: #windowSpecForCommit
   267                                     )
   241                                     )
   268                                   )
   242                                   )
   269                               )
   243                               )
   270                               #'level:' -1
   244                               #level: -1
   271                           )
   245                           )
   272                         )
   246                         )
   273                     )
   247                     )
   274                     #'handles:' #(#Any 0.368421 1.0)
   248                     #handles: #(#Any 0.368421 1.0)
   275                 )
   249                 )
   276                  #(#UISubSpecification
   250                  #(#UISubSpecification
   277                     #'name:' 'infoBarSubSpec'
   251                     #name: 'InfoBarSubSpec'
   278                     #'layout:' #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
   252                     #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
   279                     #'majorKey:' #ToolApplicationModel
   253                     #majorKey: #ToolApplicationModel
   280                     #'minorKey:' #windowSpecForInfoBar
   254                     #minorKey: #windowSpecForInfoBar
   281                 )
   255                 )
   282               )
   256               )
   283           )
   257           )
   284       )
   258       )
   285 ! !
   259 ! !
   303      
   277      
   304        #(#Menu
   278        #(#Menu
   305           
   279           
   306            #(
   280            #(
   307              #(#MenuItem
   281              #(#MenuItem
   308                 #'label:' 'About'
   282                 #label: 'About'
   309                 #'labelImage:' #(#ResourceRetriever nil #menuIcon)
   283                 #labelImage: #(#ResourceRetriever nil #menuIcon)
   310                 #'submenuChannel:' #menuAbout
   284                 #submenuChannel: #menuAbout
   311             )
   285             )
   312              #(#MenuItem
   286              #(#MenuItem
   313                 #'label:' 'File'
   287                 #label: 'File'
   314                 #'submenu:' 
   288                 #submenu: 
   315                  #(#Menu
   289                  #(#Menu
   316                     
   290                     
   317                      #(
   291                      #(
   318                        #(#MenuItem
   292                        #(#MenuItem
   319                           #'label:' 'New'
   293                           #label: 'New'
   320                           #'value:' #doNew
   294                           #value: #doNew
   321                           #'activeHelpKey:' #fileNew
   295                           #activeHelpKey: #fileNew
   322                       )
   296                       )
   323                        #(#MenuItem
   297                        #(#MenuItem
   324                           #'label:' '-'
   298                           #label: '-'
   325                       )
   299                       )
   326                        #(#MenuItem
   300                        #(#MenuItem
   327                           #'label:' 'Reload'
   301                           #label: 'Load...'
   328                           #'value:' #doReload
   302                           #translateLabel: true
   329                           #'activeHelpKey:' #fileReload
   303                           #value: #doLoad
       
   304                           #activeHelpKey: #fileLoad
   330                       )
   305                       )
   331                        #(#MenuItem
   306                        #(#MenuItem
   332                           #'label:' '-'
   307                           #label: '-'
   333                       )
   308                       )
   334                        #(#MenuItem
   309                        #(#MenuItem
   335                           #'label:' 'Save'
   310                           #label: 'Save'
   336                           #'value:' #doInstall
   311                           #value: #doSave
   337                           #'activeHelpKey:' #fileSave
   312                           #activeHelpKey: #fileSave
   338                           #'enabled:' #hasValidClass
       
   339                       )
   313                       )
   340                        #(#MenuItem
   314                        #(#MenuItem
   341                           #'label:' '-'
   315                           #label: 'Save As...'
       
   316                           #value: #doSaveAs
       
   317                           #activeHelpKey: #fileSaveAs
   342                       )
   318                       )
   343                        #(#MenuItem
   319                        #(#MenuItem
   344                           #'label:' 'Define Class And Selector...'
   320                           #label: '-'
   345                           #'value:' #doDefineClass
       
   346                           #'activeHelpKey:' #fileDefineClassAndSelector
       
   347                       )
   321                       )
   348                        #(#MenuItem
   322                        #(#MenuItem
   349                           #'label:' '-'
   323                           #label: 'Browse Class'
       
   324                           #value: #doBrowseClass
       
   325                           #activeHelpKey: #fileBrowseClass
       
   326                           #enabled: #hasValidClass
   350                       )
   327                       )
   351                        #(#MenuItem
   328                        #(#MenuItem
   352                           #'label:' 'Browse Class'
   329                           #label: '-'
   353                           #'value:' #doBrowse
       
   354                           #'activeHelpKey:' #fileBrowseClass
       
   355                           #'enabled:' #hasValidClass
       
   356                       )
   330                       )
   357                        #(#MenuItem
   331                        #(#MenuItem
   358                           #'label:' '-'
   332                           #label: 'Exit'
   359                       )
   333                           #value: #closeRequest
   360                        #(#MenuItem
   334                           #activeHelpKey: #fileExit
   361                           #'label:' 'Exit'
       
   362                           #'value:' #closeRequest
       
   363                           #'activeHelpKey:' #fileExit
       
   364                       )
   335                       )
   365                     ) nil
   336                     ) nil
   366                     nil
   337                     nil
   367                 )
   338                 )
   368             )
   339             )
   369              #(#MenuItem
   340              #(#MenuItem
   370                 #'label:' 'Edit'
   341                 #label: 'Edit'
   371                 #'submenuChannel:' #menuEdit
   342                 #submenuChannel: #menuEdit
   372             )
   343             )
   373              #(#MenuItem
   344              #(#MenuItem
   374                 #'label:' 'Add'
   345                 #label: 'Add'
   375                 #'submenu:' 
   346                 #submenu: 
   376                  #(#Menu
   347                  #(#Menu
   377                     
   348                     
   378                      #(
   349                      #(
   379                        #(#MenuItem
   350                        #(#MenuItem
   380                           #'label:' 'Child'
   351                           #label: 'Child'
   381                           #'value:' #doCreateChild
   352                           #value: #doCreateChild
   382                           #'activeHelpKey:' #addChild
   353                           #activeHelpKey: #addChild
   383                           #'enabled:' #canCreateChildChannel
   354                           #enabled: #canCreateChildChannel
   384                           #'labelImage:' #(#ResourceRetriever #HierarchicalListEditor #createChildIcon 'Child')
   355                           #labelImage: #(#ResourceRetriever #HierarchicalListEditor #createChildIcon 'Child')
   385                       )
   356                       )
   386                        #(#MenuItem
   357                        #(#MenuItem
   387                           #'label:' 'Sister'
   358                           #label: 'Sister'
   388                           #'value:' #doCreateSister
   359                           #value: #doCreateSister
   389                           #'activeHelpKey:' #addSister
   360                           #activeHelpKey: #addSister
   390                           #'enabled:' #canCreateSisterChannel
   361                           #enabled: #canCreateSisterChannel
   391                           #'labelImage:' #(#ResourceRetriever #HierarchicalListEditor #createSisterIcon 'Sister')
   362                           #labelImage: #(#ResourceRetriever #HierarchicalListEditor #createSisterIcon 'Sister')
   392                       )
   363                       )
   393                     ) nil
   364                     ) nil
   394                     nil
   365                     nil
   395                 )
   366                 )
   396             )
   367             )
   397              #(#MenuItem
   368              #(#MenuItem
   398                 #'label:' 'Help'
   369                 #label: 'History'
   399                 #'startGroup:' #right
   370                 #submenuChannel: #menuHistory
   400                 #'submenuChannel:' #menuHelp
   371             )
       
   372              #(#MenuItem
       
   373                 #label: 'Help'
       
   374                 #startGroup: #right
       
   375                 #submenuChannel: #menuHelp
   401             )
   376             )
   402           ) nil
   377           ) nil
   403           nil
   378           nil
   404       )
   379       )
   405 !
   380 !
   421      
   396      
   422        #(#Menu
   397        #(#Menu
   423           
   398           
   424            #(
   399            #(
   425              #(#MenuItem
   400              #(#MenuItem
   426                 #'label:' 'Cut'
   401                 #label: 'Cut'
   427                 #'value:' #doCut
   402                 #value: #doCut
   428                 #'activeHelpKey:' #editCut
   403                 #activeHelpKey: #editCut
   429                 #'enabled:' #canCut
   404                 #enabled: #valueOfCanCut
   430             )
   405             )
   431              #(#MenuItem
   406              #(#MenuItem
   432                 #'label:' 'Copy'
   407                 #label: 'Copy'
   433                 #'value:' #doCopy
   408                 #value: #doCopy
   434                 #'activeHelpKey:' #editCopy
   409                 #activeHelpKey: #editCopy
   435                 #'enabled:' #canCopy
   410                 #enabled: #valueOfCanCopy
   436             )
   411             )
   437              #(#MenuItem
   412              #(#MenuItem
   438                 #'label:' 'Paste'
   413                 #label: 'Paste'
   439                 #'value:' #doPaste
   414                 #value: #doPaste
   440                 #'activeHelpKey:' #editPaste
   415                 #activeHelpKey: #editPaste
   441                 #'enabled:' #canPaste
   416                 #enabled: #valueOfCanPaste
   442             )
   417             )
   443              #(#MenuItem
   418              #(#MenuItem
   444                 #'label:' '-'
   419                 #label: 'Delete'
   445             )
   420                 #value: #doDelete
   446              #(#MenuItem
   421                 #activeHelpKey: #editPaste
   447                 #'label:' 'Move Up'
   422                 #enabled: #valueOfCanCut
   448                 #'value:' #doStepUp
   423             )
   449                 #'activeHelpKey:' #editMoveUp
   424              #(#MenuItem
   450                 #'enabled:' #canStepOverChannel
   425                 #label: '-'
   451                 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up')
   426             )
   452             )
   427              #(#MenuItem
   453              #(#MenuItem
   428                 #label: 'Move Up'
   454                 #'label:' 'Move Down'
   429                 #value: #doStepUp
   455                 #'value:' #doStepDown
   430                 #activeHelpKey: #editMoveUp
   456                 #'activeHelpKey:' #editMoveDown
   431                 #enabled: #canStepOverChannel
   457                 #'enabled:' #canStepOverChannel
   432                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up')
   458                 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down')
   433             )
   459             )
   434              #(#MenuItem
   460              #(#MenuItem
   435                 #label: 'Move Down'
   461                 #'label:' 'Move In'
   436                 #value: #doStepDown
   462                 #'value:' #doStepIn
   437                 #activeHelpKey: #editMoveDown
   463                 #'activeHelpKey:' #editMoveIn
   438                 #enabled: #canStepOverChannel
   464                 #'enabled:' #canStepInChannel
   439                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down')
   465                 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In')
   440             )
   466             )
   441              #(#MenuItem
   467              #(#MenuItem
   442                 #label: 'Move In'
   468                 #'label:' 'Move Out'
   443                 #value: #doStepIn
   469                 #'value:' #doStepOut
   444                 #activeHelpKey: #editMoveIn
   470                 #'activeHelpKey:' #editMoveOut
   445                 #enabled: #canStepInChannel
   471                 #'enabled:' #canStepOutChannel
   446                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In')
   472                 #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out')
   447             )
       
   448              #(#MenuItem
       
   449                 #label: 'Move Out'
       
   450                 #value: #doStepOut
       
   451                 #activeHelpKey: #editMoveOut
       
   452                 #enabled: #canStepOutChannel
       
   453                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out')
   473             )
   454             )
   474           ) nil
   455           ) nil
   475           nil
   456           nil
   476       )
   457       )
   477 !
   458 !
   493      
   474      
   494        #(#Menu
   475        #(#Menu
   495           
   476           
   496            #(
   477            #(
   497              #(#MenuItem
   478              #(#MenuItem
   498                 #'label:' 'New'
   479                 #label: 'New'
   499                 #'isButton:' true
   480                 #isButton: true
   500                 #'value:' #doNew
   481                 #value: #doNew
   501                 #'activeHelpKey:' #fileNew
   482                 #activeHelpKey: #fileNew
   502                 #'labelImage:' #(#ResourceRetriever nil #newIcon)
   483                 #labelImage: #(#ResourceRetriever nil #newIcon)
   503             )
   484             )
   504              #(#MenuItem
   485              #(#MenuItem
   505                 #'label:' 'Save'
   486                 #label: 'Load'
   506                 #'isButton:' true
   487                 #isButton: true
   507                 #'value:' #doInstall
   488                 #value: #doLoad
   508                 #'activeHelpKey:' #fileSave
   489                 #activeHelpKey: #fileLoad
   509                 #'enabled:' #hasValidClass
   490                 #labelImage: #(#ResourceRetriever nil #loadIcon)
   510                 #'labelImage:' #(#ResourceRetriever nil #saveIcon)
   491             )
   511             )
   492              #(#MenuItem
   512              #(#MenuItem
   493                 #label: 'Save'
   513                 #'label:' ''
   494                 #isButton: true
   514             )
   495                 #value: #doSave
   515              #(#MenuItem
   496                 #activeHelpKey: #fileSave
   516                 #'label:' 'Add Child'
   497                 #labelImage: #(#ResourceRetriever nil #saveIcon)
   517                 #'isButton:' true
   498             )
   518                 #'value:' #doCreateChild
   499              #(#MenuItem
   519                 #'activeHelpKey:' #addChild
   500                 #label: ''
   520                 #'enabled:' #canCreateChildChannel
   501             )
   521                 #'labelImage:' #(#ResourceRetriever nil #createChildIcon)
   502              #(#MenuItem
   522             )
   503                 #label: 'Cut'
   523              #(#MenuItem
   504                 #isButton: true
   524                 #'label:' 'Add Sister'
   505                 #value: #doCut
   525                 #'isButton:' true
   506                 #activeHelpKey: #editCut
   526                 #'value:' #doCreateSister
   507                 #enabled: #valueOfCanCut
   527                 #'activeHelpKey:' #addSister
   508                 #labelImage: #(#ResourceRetriever nil #cutIcon)
   528                 #'enabled:' #canCreateSisterChannel
   509             )
   529                 #'labelImage:' #(#ResourceRetriever nil #createSisterIcon)
   510              #(#MenuItem
   530             )
   511                 #label: 'Copy'
   531              #(#MenuItem
   512                 #isButton: true
   532                 #'label:' ''
   513                 #value: #doCopy
   533             )
   514                 #activeHelpKey: #editCopy
   534              #(#MenuItem
   515                 #enabled: #valueOfCanCopy
   535                 #'label:' 'Move Up'
   516                 #labelImage: #(#ResourceRetriever nil #copyIcon)
   536                 #'isButton:' true
   517             )
   537                 #'value:' #doStepUp
   518              #(#MenuItem
   538                 #'activeHelpKey:' #editMoveUp
   519                 #label: 'Paste'
   539                 #'enabled:' #canStepOverChannel
   520                 #isButton: true
   540                 #'labelImage:' #(#ResourceRetriever nil #upIcon)
   521                 #value: #doPaste
   541             )
   522                 #activeHelpKey: #editPaste
   542              #(#MenuItem
   523                 #enabled: #valueOfCanPaste
   543                 #'label:' 'Move Down'
   524                 #labelImage: #(#ResourceRetriever nil #pasteIcon)
   544                 #'isButton:' true
   525             )
   545                 #'value:' #doStepDown
   526              #(#MenuItem
   546                 #'activeHelpKey:' #editMoveDown
   527                 #label: 'Delete'
   547                 #'enabled:' #canStepOverChannel
   528                 #isButton: true
   548                 #'labelImage:' #(#ResourceRetriever nil #downIcon)
   529                 #value: #doDelete
   549             )
   530                 #activeHelpKey: #editDelete
   550              #(#MenuItem
   531                 #enabled: #valueOfCanCut
   551                 #'label:' 'Move In'
   532                 #labelImage: #(#ResourceRetriever nil #deleteIcon)
   552                 #'isButton:' true
   533             )
   553                 #'value:' #doStepIn
   534              #(#MenuItem
   554                 #'activeHelpKey:' #editMoveIn
   535                 #label: ''
   555                 #'enabled:' #canStepInChannel
   536             )
   556                 #'labelImage:' #(#ResourceRetriever nil #downRightIcon)
   537              #(#MenuItem
   557             )
   538                 #label: 'Add Child'
   558              #(#MenuItem
   539                 #isButton: true
   559                 #'label:' 'Move Out'
   540                 #value: #doCreateChild
   560                 #'isButton:' true
   541                 #activeHelpKey: #addChild
   561                 #'value:' #doStepOut
   542                 #enabled: #canCreateChildChannel
   562                 #'activeHelpKey:' #editMoveOut
   543                 #labelImage: #(#ResourceRetriever nil #createChildIcon)
   563                 #'enabled:' #canStepOutChannel
   544             )
   564                 #'labelImage:' #(#ResourceRetriever nil #leftDownIcon)
   545              #(#MenuItem
       
   546                 #label: 'Add Sister'
       
   547                 #isButton: true
       
   548                 #value: #doCreateSister
       
   549                 #activeHelpKey: #addSister
       
   550                 #enabled: #canCreateSisterChannel
       
   551                 #labelImage: #(#ResourceRetriever nil #createSisterIcon)
       
   552             )
       
   553              #(#MenuItem
       
   554                 #label: ''
       
   555             )
       
   556              #(#MenuItem
       
   557                 #label: 'Move Up'
       
   558                 #isButton: true
       
   559                 #value: #doStepUp
       
   560                 #activeHelpKey: #editMoveUp
       
   561                 #enabled: #canStepOverChannel
       
   562                 #labelImage: #(#ResourceRetriever nil #upIcon)
       
   563             )
       
   564              #(#MenuItem
       
   565                 #label: 'Move Down'
       
   566                 #isButton: true
       
   567                 #value: #doStepDown
       
   568                 #activeHelpKey: #editMoveDown
       
   569                 #enabled: #canStepOverChannel
       
   570                 #labelImage: #(#ResourceRetriever nil #downIcon)
       
   571             )
       
   572              #(#MenuItem
       
   573                 #label: 'Move In'
       
   574                 #isButton: true
       
   575                 #value: #doStepIn
       
   576                 #activeHelpKey: #editMoveIn
       
   577                 #enabled: #canStepInChannel
       
   578                 #labelImage: #(#ResourceRetriever nil #downRightIcon)
       
   579             )
       
   580              #(#MenuItem
       
   581                 #label: 'Move Out'
       
   582                 #isButton: true
       
   583                 #value: #doStepOut
       
   584                 #activeHelpKey: #editMoveOut
       
   585                 #enabled: #canStepOutChannel
       
   586                 #labelImage: #(#ResourceRetriever nil #leftDownIcon)
   565             )
   587             )
   566           ) nil
   588           ) nil
   567           nil
   589           nil
   568       )
   590       )
   569 ! !
   591 ! !
   619     ].
   641     ].
   620     aStream nextPut:$).
   642     aStream nextPut:$).
   621     aStream cr.
   643     aStream cr.
   622 ! !
   644 ! !
   623 
   645 
   624 !HierarchicalListEditor class methodsFor:'resources'!
       
   625 
       
   626 createChildIcon
       
   627     "Generated by the Image Editor"
       
   628     "
       
   629     ImageEditor openOnClass:self andSelector:#createChildIcon
       
   630     "
       
   631 
       
   632     <resource: #image>
       
   633 
       
   634     ^Icon
       
   635         constantNamed:#'HierarchicalListEditor createChildIcon'
       
   636         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*****(@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); 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]!
       
   637 
       
   638 createSisterIcon
       
   639     "Generated by the Image Editor"
       
   640     "
       
   641     ImageEditor openOnClass:self andSelector:#createSisterIcon
       
   642     "
       
   643 
       
   644     <resource: #image>
       
   645 
       
   646     ^Icon
       
   647         constantNamed:#'HierarchicalListEditor createSisterIcon'
       
   648         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*****(@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); 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]! !
       
   649 
       
   650 !HierarchicalListEditor methodsFor:'accessing'!
       
   651 
       
   652 didInstall
       
   653     "returns true if spec was installed by operator"
       
   654 
       
   655     ^didInstall ? false
       
   656 !
       
   657 
       
   658 selectorName
       
   659     "returns current spec. selector"
       
   660 
       
   661     ^specSelector
       
   662 ! !
       
   663 
       
   664 !HierarchicalListEditor methodsFor:'aspects'!
   646 !HierarchicalListEditor methodsFor:'aspects'!
   665 
   647 
   666 canCreateChildChannel
   648 canCreateChildChannel
   667     "automatically generated by UIPainter ..."
       
   668 
   649 
   669     ^builder booleanValueAspectFor:#canCreateChildChannel
   650     ^builder booleanValueAspectFor:#canCreateChildChannel
   670 
   651 
   671 !
   652 !
   672 
   653 
   673 canCreateSisterChannel
   654 canCreateSisterChannel
   674     "automatically generated by UIPainter ..."
       
   675 
   655 
   676     ^builder booleanValueAspectFor:#canCreateSisterChannel
   656     ^builder booleanValueAspectFor:#canCreateSisterChannel
   677 
   657 
   678 !
   658 !
   679 
   659 
   680 canStepInChannel
   660 canStepInChannel
   681     "automatically generated by UIPainter ..."
       
   682 
   661 
   683     ^builder booleanValueAspectFor:#canStepInChannel
   662     ^builder booleanValueAspectFor:#canStepInChannel
   684 
   663 
   685 !
   664 !
   686 
   665 
   687 canStepOutChannel
   666 canStepOutChannel
   688     "automatically generated by UIPainter ..."
       
   689 
   667 
   690     ^builder booleanValueAspectFor:#canStepOutChannel
   668     ^builder booleanValueAspectFor:#canStepOutChannel
   691 
   669 
   692 !
   670 !
   693 
   671 
   694 canStepOverChannel
   672 canStepOverChannel
   695     "automatically generated by UIPainter ..."
       
   696 
   673 
   697     ^builder booleanValueAspectFor:#canStepOverChannel
   674     ^builder booleanValueAspectFor:#canStepOverChannel
   698 
   675 
   699 !
   676 !
   700 
   677 
   701 hasValidClass
       
   702     "automatically generated by UIPainter ..."
       
   703 
       
   704     ^builder booleanValueAspectFor:#hasValidClass
       
   705 
       
   706 !
       
   707 
       
   708 itemName
   678 itemName
   709     "automatically generated by UIPainter ..."
       
   710 
   679 
   711     |holder|
   680     |holder|
   712 
   681 
   713     (holder := builder bindingAt:#itemName) isNil ifTrue:[
   682     (holder := builder bindingAt:#itemName) isNil ifTrue:[
   714         builder aspectAt:#itemName put:(holder :=  ValueHolder new).
   683         builder aspectAt:#itemName put:(holder :=  ValueHolder new).
   716     ].
   685     ].
   717     ^ holder
   686     ^ holder
   718 !
   687 !
   719 
   688 
   720 itemValue
   689 itemValue
   721     "automatically generated by UIPainter ..."
       
   722 
   690 
   723     |holder|
   691     |holder|
   724 
   692 
   725     (holder := builder bindingAt:#itemValue) isNil ifTrue:[
   693     (holder := builder bindingAt:#itemValue) isNil ifTrue:[
   726         builder aspectAt:#itemValue put:(holder :=  ValueHolder new).
   694         builder aspectAt:#itemValue put:(holder :=  ValueHolder new).
   728     ].
   696     ].
   729     ^ holder
   697     ^ holder
   730 !
   698 !
   731 
   699 
   732 treeView
   700 treeView
   733     "automatically generated by UIPainter ..."
       
   734 
   701 
   735     ^treeView
   702     ^treeView
   736 ! !
   703 ! !
   737 
   704 
   738 !HierarchicalListEditor methodsFor:'change & update'!
   705 !HierarchicalListEditor methodsFor:'building'!
   739 
   706 
   740 update:something with:aParameter from:someObject
   707 buildFromClass:aClass andSelector:aSelector
   741     "one of my models changed"
   708     "rebuild window from a class and selector"
   742 
   709 
   743     self valueOfEnablingCommitButtons value: true
   710     |cls sel anchor|
   744 ! !
   711 
   745 
   712     cls := self resolveName:aClass.
   746 !HierarchicalListEditor methodsFor:'help'!
   713     specSelector := nil.
   747 
   714 
   748 defaultInfoLabel
   715     aSelector size ~~ 0 
   749 
   716     ifTrue:
   750     specClass isNil ifTrue: [^'No hierarchical list class defined'].
   717     [
   751     ^specClass name, ' >> ', specSelector printString
   718         sel := aSelector asString withoutSeparators.
   752 
   719         sel size ~~ 0 ifTrue:[specSelector := sel asSymbol]
       
   720     ].
       
   721     treeView selection:nil.
       
   722 
       
   723     (specSelector notNil and:[cls notNil]) 
       
   724     ifTrue:
       
   725     [
       
   726         (cls respondsTo:specSelector) 
       
   727         ifTrue:
       
   728         [
       
   729             anchor := cls perform:specSelector.
       
   730             anchor isArray ifTrue:[anchor := anchor decodeAsLiteralArray]
       
   731         ].
       
   732     ].              
       
   733     anchor notNil     
       
   734         ifTrue:  [anchor expand. treeView root:anchor] 
       
   735         ifFalse: [treeView root isNil ifTrue: [self buildRoot]].
       
   736 
       
   737     treeView selection: 1.
       
   738 
       
   739     self updateHistory.
       
   740     self updateInfoLabel.
       
   741 
       
   742 
       
   743 
       
   744 !
       
   745 
       
   746 buildFromListSpec: aListSpec
       
   747 
       
   748     treeView root: aListSpec
       
   749 
       
   750 !
       
   751 
       
   752 buildRoot
       
   753     "build just a root"
       
   754 
       
   755     treeView root:(TreeItem name:'Root' contents:#Anchor).
       
   756     treeView selection:1.
   753 ! !
   757 ! !
   754 
   758 
   755 !HierarchicalListEditor methodsFor:'private'!
   759 !HierarchicalListEditor methodsFor:'private'!
   756 
   760 
   757 checkMenuItemModified
   761 getDepthAndSistersNumberOfNode: aNode onParentNode: aParentNode
   758     "check item modification"
   762     "return depth of selected node"
   759 
   763 
   760     self valueOfEnablingCommitButtons value
   764     |parent childNode depthAndSistersNumbers str|
   761     ifTrue:
   765 
   762     [
   766     depthAndSistersNumbers := OrderedCollection new.
   763         ((YesNoBox title:'Item was modified!!\Save it?\' withCRs)        
   767     childNode := aNode.
   764             noText:'No';
   768     parent := aParentNode.
   765             yesText:'Yes';
   769     [parent notNil] 
   766             showAtPointer;
   770     whileTrue: 
   767             accepted) ifFalse: [self valueOfEnablingCommitButtons value: false. ^true].
   771     [
   768         self accept
   772         depthAndSistersNumbers add: (parent children indexOf: childNode). 
       
   773         childNode := parent. 
       
   774         parent := parent parent. 
   769     ].
   775     ].
   770     ^true
   776     depthAndSistersNumbers removeFirst; addFirst: aParentNode children size.
   771 !
   777     str := ''.
   772 
   778     depthAndSistersNumbers reverseDo: [:n| str := str, n printString, '.'].
   773 checkModified
   779     ^str copyFrom: 1 to: str size - 1
   774     "check menu modification
       
   775     "
       
   776     isModified
       
   777     ifTrue:
       
   778     [
       
   779         ((YesNoBox title:'Hierarchical list was modified!!')        
       
   780             noText:'Cancel';
       
   781             yesText:'Waste it and proceed';
       
   782             showAtPointer;
       
   783             accepted) ifFalse: [^false].
       
   784         isModified := false
       
   785     ].
       
   786     ^true
       
   787 !
   780 !
   788 
   781 
   789 newItem
   782 newItem
   790     "creates and returns a new default item"
   783     "creates and returns a new default item"
   791 
   784 
   800     chnStepIn := chnStepOut := chnStepOvr := chnChild := chnSister := false.
   793     chnStepIn := chnStepOut := chnStepOvr := chnChild := chnSister := false.
   801 
   794 
   802     (node := treeView selectedNode) notNil 
   795     (node := treeView selectedNode) notNil 
   803     ifTrue:
   796     ifTrue:
   804     [
   797     [
   805         (builder componentAt: #specView) beVisible.
   798         (builder componentAt: #SpecView) beVisible.
   806         chnChild := true.
   799         chnChild := true.
   807         (parent := node parent) notNil 
   800         (parent := node parent) notNil 
   808         ifTrue:
   801         ifTrue:
   809         [
   802         [
   810             chnSister  := true.
   803             chnSister  := true.
   813             chnStepIn  := node ~~ parent lastChild
   806             chnStepIn  := node ~~ parent lastChild
   814         ]
   807         ]
   815     ]
   808     ]
   816     ifFalse:
   809     ifFalse:
   817     [
   810     [
   818         (builder componentAt: #specView) beInvisible
   811         (builder componentAt: #SpecView) beInvisible
   819     ].
   812     ].
   820     self canCreateChildChannel  value:chnChild.
   813     self canCreateChildChannel  value:chnChild.
   821     self canCreateSisterChannel value:chnSister.
   814     self canCreateSisterChannel value:chnSister.
   822     self canStepOverChannel     value:chnStepOvr.
   815     self canStepOverChannel     value:chnStepOvr.
   823     self canStepOutChannel      value:chnStepOut.
   816     self canStepOutChannel      value:chnStepOut.
   824     self canStepInChannel       value:chnStepIn.
   817     self canStepInChannel       value:chnStepIn.
   825 
   818 
   826 
   819     self valueOfCanCut value: (treeView selection notNil      
       
   820         ifTrue:[(treeView isInSelection:1) not] 
       
   821         ifFalse: [false]).
       
   822 
       
   823     self valueOfCanCopy value: self valueOfCanCut value.
       
   824 
       
   825     self valueOfCanPaste value: (self class clipboard notNil and:[treeView selectedNode notNil]).
   827 !
   826 !
   828 
   827 
   829 updateInputFields
   828 updateInputFields
   830     "reload item value into input fields"
   829     "reload item value into input fields"
   831 
   830 
   843         self itemValue value:nil
   842         self itemValue value:nil
   844     ].
   843     ].
   845     self valueOfEnablingCommitButtons value: false
   844     self valueOfEnablingCommitButtons value: false
   846 ! !
   845 ! !
   847 
   846 
   848 !HierarchicalListEditor methodsFor:'queries'!
       
   849 
       
   850 canChangeClassName
       
   851     "returns true if current class could be changed which is dependent on
       
   852      the mode: standalone or started by UIPainter"
       
   853 
       
   854     ^masterApplication isNil
       
   855 !
       
   856 
       
   857 canCopy
       
   858     "returns true if any selection exists"
       
   859 
       
   860     ^treeView selection notNil
       
   861 !
       
   862 
       
   863 canCut
       
   864     "returns true if any selection exists and not includes
       
   865      the anchor (first element into list)."
       
   866 
       
   867     treeView selection notNil ifTrue:[^(treeView isInSelection:1) not].
       
   868     ^false
       
   869 !
       
   870 
       
   871 canPaste
       
   872     "returns true if something to be paste exists and a
       
   873      single selection exists"
       
   874 
       
   875     ^CopyBuffer notNil and:[treeView selectedNode notNil]
       
   876 !
       
   877 
       
   878 hasValidMethodSelector
       
   879     "returns true if the class and the instance selector defined
       
   880      allready exists."
       
   881 
       
   882     (specSelector notNil and:[self hasValidClass]) 
       
   883     ifTrue:
       
   884     [
       
   885         ^(specClass compiledMethodAt:specSelector) notNil
       
   886     ].    
       
   887     ^false
       
   888 !
       
   889 
       
   890 hasValidSpecSelector
       
   891     "returns true if the class and the class selector defined
       
   892      allready exists."
       
   893 
       
   894     (specSelector notNil and:[self hasValidClass])
       
   895     ifTrue:
       
   896     [
       
   897         ^(specClass class compiledMethodAt:specSelector) notNil
       
   898     ].
       
   899     ^false
       
   900 ! !
       
   901 
       
   902 !HierarchicalListEditor methodsFor:'startup / release'!
   847 !HierarchicalListEditor methodsFor:'startup / release'!
   903 
       
   904 buildFrom:aClass andSelector:aSelector
       
   905     "rebuild window from a class and selector"
       
   906 
       
   907     |sel anchor|
       
   908 
       
   909     specClass := self resolveName:aClass.
       
   910     specSelector := nil.
       
   911 
       
   912     aSelector size ~~ 0 
       
   913     ifTrue:
       
   914     [
       
   915         sel := aSelector asString withoutSeparators.
       
   916         sel size ~~ 0 ifTrue:[specSelector := sel asSymbol]
       
   917     ].
       
   918     treeView selection:nil.
       
   919 
       
   920     (specSelector notNil and:[specClass notNil]) 
       
   921     ifTrue:
       
   922     [
       
   923         (specClass respondsTo:specSelector) 
       
   924         ifTrue:
       
   925         [
       
   926             anchor := specClass perform:specSelector.
       
   927             anchor isArray ifTrue:[anchor := anchor decodeAsLiteralArray]
       
   928         ].
       
   929         self hasValidClass value: true
       
   930     ].
       
   931     anchor notNil 
       
   932         ifTrue: [anchor expand. treeView root:anchor] 
       
   933         ifFalse:[self doNew]
       
   934 !
       
   935 
       
   936 closeRequest
       
   937     "close request"
       
   938 
       
   939     (self checkMenuItemModified and: [self checkModified]) ifTrue: [super closeRequest]
       
   940 
       
   941 
       
   942 !
       
   943 
   848 
   944 initialize
   849 initialize
   945     "setup default values"
   850     "setup default values"
   946 
   851 
   947     super initialize.
   852     super initialize.
   949     treeView := SelectionInTreeView new.
   854     treeView := SelectionInTreeView new.
   950     treeView multipleSelectOk: true.
   855     treeView multipleSelectOk: true.
   951     treeView showDirectoryIndicator: true.
   856     treeView showDirectoryIndicator: true.
   952     treeView showDirectoryIndicatorForRoot: false.
   857     treeView showDirectoryIndicatorForRoot: false.
   953     treeView action:[:aNr| self updateChannels. self updateInputFields].
   858     treeView action:[:aNr| self updateChannels. self updateInputFields].
   954     treeView selectConditionBlock: [:i|self checkMenuItemModified].
   859     treeView selectConditionBlock: [:i|self askForItemModification].
   955     treeView validateDoubleClickBlock: [:node| node ~~ treeView model list first].
   860     treeView validateDoubleClickBlock: [:node| node ~~ treeView model list first].
   956 !
   861 !
   957 
   862 
   958 openModalOnClass:aClass andSelector:aSelector
   863 openModalOnTreeItem: aTreeItem
   959     "open modal on class and selector"
   864     "build a tree from aTreeItem and open it modal"
   960 
   865 
   961     specClass := Association key:aClass value:aSelector.
   866     super openModalOnListSpec: aTreeItem
   962     super openInterfaceModal.
       
   963 
       
   964 
       
   965 !
       
   966 
       
   967 openOnClass:aClass andSelector:aSelector
       
   968     "open on class and selector"
       
   969 
       
   970     specClass := Association key:aClass value:aSelector.
       
   971     super openInterface.
       
   972 
       
   973 !
       
   974 
       
   975 postBuildWith:builder
       
   976     "setup view"
       
   977 
       
   978     |cls sel|
       
   979 
       
   980     specClass isAssociation ifTrue:[
       
   981         cls := specClass key.
       
   982         sel := specClass value.
       
   983     ].
       
   984     self buildFrom:cls andSelector:sel.
       
   985 
       
   986     isModified := false
       
   987 
       
   988 ! !
   867 ! !
   989 
   868 
   990 !HierarchicalListEditor methodsFor:'user actions'!
   869 !HierarchicalListEditor methodsFor:'user actions'!
   991 
   870 
   992 accept
   871 accept
  1000         node := treeView nodeAtIndex:index.
   879         node := treeView nodeAtIndex:index.
  1001         node name: self itemName value.
   880         node name: self itemName value.
  1002         node contents: self itemValue value.
   881         node contents: self itemValue value.
  1003         treeView redrawLine:index.
   882         treeView redrawLine:index.
  1004     ].
   883     ].
  1005     isModified := true.
   884     modified := true.
  1006     self valueOfEnablingCommitButtons value: false
   885     self valueOfEnablingCommitButtons value: false
  1007 !
   886 !
  1008 
   887 
  1009 cancel
   888 cancel
  1010     "invoked by button 'Cancel'"
   889     "invoked by button 'Cancel'"
  1011 
   890 
  1012     self updateInputFields.
   891     self updateInputFields.
  1013 
   892 
  1014     isModified := false.
   893     modified := false.
  1015     self valueOfEnablingCommitButtons value: false
   894     self valueOfEnablingCommitButtons value: false
  1016 !
       
  1017 
       
  1018 doBrowse
       
  1019     "open a system browser"
       
  1020 
       
  1021     SystemBrowser openInClass: specClass class selector: specSelector
       
  1022 
       
  1023 !
   895 !
  1024 
   896 
  1025 doCopy
   897 doCopy
  1026     "copy current selected nodes into copy buffer"
   898     "copy current selected nodes into copy buffer"
  1027 
   899 
  1028     CopyBuffer := OrderedCollection new.
   900     self class clipboard: OrderedCollection new.
  1029     treeView selectedNodesDo:[:aNode| CopyBuffer add: aNode copy]
   901     treeView selectedNodesDo:[:aNode| self class clipboard add: aNode copy]
  1030 
   902 
  1031 !
   903 !
  1032 
   904 
  1033 doCreateChild
   905 doCreateChild
  1034     "create a child within selected parent"
   906     "create a child within selected parent"
  1035 
   907 
  1036     |node newItem|
   908     |node newItem|
  1037 
   909 
  1038     ((node := treeView selectedNode) notNil and: [self checkMenuItemModified])
   910     ((node := treeView selectedNode) notNil and: [self askForItemModification])
  1039     ifTrue:
   911     ifTrue:
  1040     [
   912     [
  1041         treeView model add: (newItem := self newItem) afterIndex: node children size below:node.
   913         treeView model add: (newItem := self newItem) afterIndex: node children size below:node.
  1042         newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node).
   914         newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node).
  1043         treeView selectedNodeExpand:true.
   915         treeView selectedNodeExpand:true.
  1044         treeView selectNode: newItem.
   916         treeView selectNode: newItem.
  1045         self updateChannels.
   917         self updateChannels.
  1046         isModified := true
   918         modified := true
  1047     ]
   919     ]
  1048 !
   920 !
  1049 
   921 
  1050 doCreateSister
   922 doCreateSister
  1051     "create a sister next to selected item
   923     "create a sister next to selected item
  1052     "
   924     "
  1053     |node newItem|
   925     |node newItem|
  1054 
   926 
  1055     ((node := treeView selectedNode) notNil and: [self checkMenuItemModified]) 
   927     ((node := treeView selectedNode) notNil and: [self askForItemModification]) 
  1056     ifTrue:
   928     ifTrue:
  1057     [
   929     [
  1058         newItem := self newItem.
   930         newItem := self newItem.
  1059         node parent notNil 
   931         node parent notNil 
  1060             ifTrue: [treeView model add: newItem after:node] 
   932             ifTrue: [treeView model add: newItem after:node] 
  1061             ifFalse:[treeView model add: newItem beforeIndex:1 below:node].
   933             ifFalse:[treeView model add: newItem beforeIndex:1 below:node].
  1062 
   934 
  1063         newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node parent).
   935         newItem name: 'Child ', (self getDepthAndSistersNumberOfNode: newItem onParentNode: node parent).
  1064         treeView selectNode: newItem.
   936         treeView selectNode: newItem.
  1065         self updateChannels.
   937         self updateChannels.
  1066         isModified := true
   938         modified := true
  1067     ]
   939     ]
  1068 !
   940 !
  1069 
   941 
  1070 doCut
   942 doCut
  1071     "cut current selected nodes"
   943     "cut current selected nodes"
  1072 
   944 
  1073     |selection|
   945     |selection|
  1074     (treeView hasSelection and: [self checkMenuItemModified]) 
   946     (treeView hasSelection and: [self askForItemModification]) 
  1075     ifTrue:
   947     ifTrue:
  1076     [
   948     [
  1077         self doCopy.
   949         self doCopy.
  1078         selection := treeView selection asSortedCollection.
   950         selection := treeView selection asSortedCollection.
  1079         treeView selectedNodesRemove.
   951         treeView selectedNodesRemove.
  1080         treeView selection: selection first - 1.
   952         treeView selection: selection first - 1.
  1081         self updateChannels.
   953         self updateChannels.
  1082         isModified := true
   954         modified := true
  1083     ]
   955     ]
  1084 !
   956 !
  1085 
   957 
  1086 doDefineClass
   958 doDelete
  1087     "define class and selector"
   959     "delete current selected nodes"
  1088 
   960 
  1089     |sel cls bindings accepted|
   961     |selection|
  1090 
   962     (treeView hasSelection and: [self askForItemModification]) 
  1091     accepted := true.
   963     ifTrue:
  1092     bindings := IdentityDictionary new.
   964     [
  1093 
   965         selection := treeView selection asSortedCollection.
  1094     specClass    notNil ifTrue:[cls := specClass name asString]
   966         treeView selectedNodesRemove.
  1095                        ifFalse:[cls := ''].
   967         treeView selection: selection first - 1.
  1096 
   968         self updateChannels.
  1097     specSelector notNil ifTrue:[sel := specSelector asString]
   969         modified := true
  1098                        ifFalse:[sel := ''].
       
  1099 
       
  1100     bindings at:#specSelectorChannel put: sel asValue.
       
  1101     bindings at:#specClassChannel    put: cls asValue.
       
  1102 
       
  1103     [accepted] 
       
  1104     whileTrue:
       
  1105     [
       
  1106         (accepted := self openDialogInterface:#classAndMethodSpec withBindings:bindings)
       
  1107         ifTrue:
       
  1108         [
       
  1109             (cls := self resolveName:(bindings at:#specClassChannel) value) notNil 
       
  1110             ifTrue:
       
  1111             [
       
  1112                 (sel := (bindings at:#specSelectorChannel) value withoutSeparators) size ~~ 0 
       
  1113                 ifTrue:
       
  1114                 [
       
  1115                     specClass    := cls.
       
  1116                     specSelector := sel asSymbol.
       
  1117                     self hasValidClass value: true.
       
  1118                     isModified := true.
       
  1119                     self updateInfoLabel.
       
  1120                     ^self
       
  1121                 ]
       
  1122             ]
       
  1123         ]
       
  1124     ]
   970     ]
  1125 
   971 !
  1126 !
   972 
  1127 
   973 doNew
  1128 doInstall
   974     "remove all items; restart"
       
   975 
       
   976     self askForModification
       
   977     ifTrue: 
       
   978     [
       
   979         self isStandAlone ifTrue: [specClass := specSelector := nil].
       
   980         self buildRoot
       
   981     ]
       
   982 
       
   983 
       
   984 
       
   985 !
       
   986 
       
   987 doPaste
       
   988     "paste after current selected item"
       
   989 
       
   990     self askForItemModification
       
   991     ifTrue:
       
   992     [
       
   993         |copiedNode|
       
   994         self class clipboard do:
       
   995         [:node|
       
   996             copiedNode := node copy.
       
   997             treeView selectedNodeAdd: copiedNode. 
       
   998             treeView selectNode: copiedNode.
       
   999         ].
       
  1000         self updateChannels.
       
  1001         modified := true
       
  1002     ]
       
  1003 !
       
  1004 
       
  1005 doReload
       
  1006     "reload spec from current class and selector"
       
  1007 
       
  1008     self buildFrom:specClass andSelector:specSelector
       
  1009 
       
  1010 !
       
  1011 
       
  1012 doSave
  1129     "install code"
  1013     "install code"
  1130 
  1014 
  1131     |code spec category mthd stream|
  1015     |cls code spec category mthd stream|
  1132 
  1016 
  1133     (specClass notNil and:[specSelector notNil])
  1017     (specClass notNil and:[specSelector notNil])
  1134     ifFalse:
  1018     ifFalse:
  1135     [
  1019     [
  1136         ^self information:'No valid class and method defined!!'
  1020         ^self doSaveAs
  1137     ].
  1021     ].
  1138 
  1022 
       
  1023     cls := self resolveName: specClass.
  1139     spec   := (treeView nodeAtIndex:1) literalArrayEncoding.
  1024     spec   := (treeView nodeAtIndex:1) literalArrayEncoding.
  1140     stream := WriteStream on:String new.
  1025     stream := WriteStream on:String new.
  1141     self class prettyPrintArray:spec on:stream indent:4.
  1026     self class prettyPrintArray:spec on:stream indent:4.
  1142     spec       := stream contents.
  1027     spec       := stream contents.
  1143     category   := 'interface specs'.
  1028     category   := 'list specs'.
  1144     didInstall := true.
  1029 
  1145     isModified := false.
  1030     (mthd := cls class compiledMethodAt:specSelector) notNil 
  1146 
       
  1147     (mthd := specClass class compiledMethodAt:specSelector) notNil 
       
  1148     ifTrue:
  1031     ifTrue:
  1149     [
  1032     [
  1150         category := mthd category
  1033         category := mthd category
  1151     ].
  1034     ].
  1152 
  1035 
  1153     code := Character excla asString 
  1036     code := Character excla asString 
  1154             , specClass name , ' class methodsFor:' , category storeString
  1037             , cls name , ' class methodsFor:' , category storeString
  1155             , Character excla asString , '\\'
  1038             , Character excla asString , '\\'
  1156 
  1039 
  1157             , specSelector , '\'
  1040             , specSelector , '\'
  1158             , '    "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\'
  1041             , '    "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\'
  1159             , '    "do not manually edit this - the builder may not be able to\'
  1042             , '    "do not manually edit this - the builder may not be able to\'
  1160             , '     handle the specification if its corrupted."\\'
  1043             , '     handle the specification if its corrupted."\\'
  1161             , '    "\'
  1044             , '    "\'
  1162             , '     HierarchicalListEditor new openOnClass:' , specClass name , ' andSelector:#' , specSelector , '\'
  1045             , '     HierarchicalListEditor openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
  1163             , '    "\'.
  1046             , '    "\'.
  1164 
  1047 
  1165     code := code 
  1048     code := code 
  1166             , '\'
  1049             , '\'
  1167             , '    <resource: #hierarchicalList>\\'
  1050             , '    <resource: #hierarchicalList>\\'
  1174             , '\\'.
  1057             , '\\'.
  1175 
  1058 
  1176     code := code withCRs.
  1059     code := code withCRs.
  1177     (ReadStream on:code) fileIn.
  1060     (ReadStream on:code) fileIn.
  1178 
  1061 
  1179     (specClass compiledMethodAt:specSelector) isNil 
  1062     self updateHistory.
  1180     ifTrue:
  1063     hasSaved := true.
  1181     [
  1064     modified := false.
  1182         category := 'aspects'.
       
  1183 
       
  1184         code := Character excla asString 
       
  1185                 , specClass name , ' methodsFor:' , category storeString
       
  1186                 , Character excla asString , '\\'
       
  1187 
       
  1188                 , specSelector , '\'
       
  1189                 , '    "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\'
       
  1190                 , '    ^ self class ', specSelector
       
  1191                 , '\'
       
  1192                 , Character excla asString
       
  1193                 , ' '
       
  1194                 , Character excla asString
       
  1195                 , '\\'.
       
  1196 
       
  1197         code := code withCRs.
       
  1198         (ReadStream on:code) fileIn
       
  1199     ]
       
  1200 
       
  1201 
       
  1202 !
       
  1203 
       
  1204 doNew
       
  1205     "remove all items; restart"
       
  1206 
       
  1207     treeView root:(TreeItem name:'Root' contents:#anchor).
       
  1208     treeView selection:1.
       
  1209     isModified := true.
       
  1210 
       
  1211 
       
  1212 
       
  1213 !
       
  1214 
       
  1215 doPaste
       
  1216     "paste after current selected item"
       
  1217 
       
  1218     self checkMenuItemModified
       
  1219     ifTrue:
       
  1220     [
       
  1221         treeView selectedNodeAdd:CopyBuffer.
       
  1222         CopyBuffer isCollection ifFalse: [treeView selectNode: CopyBuffer] ifTrue: [treeView selection: (CopyBuffer collect: [:node| treeView indexOfNode: node])].
       
  1223         self updateChannels.
       
  1224         isModified := true
       
  1225     ]
       
  1226 !
       
  1227 
       
  1228 doReload
       
  1229     "reload spec from current class and selector"
       
  1230 
       
  1231     self buildFrom:specClass andSelector:specSelector
       
  1232 
       
  1233 !
  1065 !
  1234 
  1066 
  1235 doStepDown
  1067 doStepDown
  1236     "move selected item after next item"
  1068     "move selected item after next item"
  1237 
  1069 
  1238     treeView selectedNodeChangeSequenceOrder:1.
  1070     treeView selectedNodeChangeSequenceOrder:1.
  1239     self updateChannels.
  1071     self updateChannels.
  1240     isModified := true
  1072     modified := true
  1241 
  1073 
  1242 !
  1074 !
  1243 
  1075 
  1244 doStepIn
  1076 doStepIn
  1245     "lets become the selected item a child of its next sister"
  1077     "lets become the selected item a child of its next sister"
  1246 
  1078 
  1247     treeView selectedNodeBecomeChildOfNext.
  1079     treeView selectedNodeBecomeChildOfNext.
  1248     self updateChannels.
  1080     self updateChannels.
  1249     isModified := true
  1081     modified := true
  1250 
  1082 
  1251 
  1083 
  1252 
  1084 
  1253 !
  1085 !
  1254 
  1086 
  1255 doStepOut
  1087 doStepOut
  1256     "let selected node become a sister of its current parent"
  1088     "let selected node become a sister of its current parent"
  1257 
  1089 
  1258     treeView selectedNodeBecomeSisterOfParent.
  1090     treeView selectedNodeBecomeSisterOfParent.
  1259     self updateChannels.
  1091     self updateChannels.
  1260     isModified := true
  1092     modified := true
  1261 
  1093 
  1262 
  1094 
  1263 
  1095 
  1264 !
  1096 !
  1265 
  1097 
  1266 doStepUp
  1098 doStepUp
  1267     "move selected item before previous item"
  1099     "move selected item before previous item"
  1268 
  1100 
  1269     treeView selectedNodeChangeSequenceOrder:-1.
  1101     treeView selectedNodeChangeSequenceOrder:-1.
  1270     self updateChannels.
  1102     self updateChannels.
  1271     isModified := true
  1103     modified := true
  1272 
  1104 
  1273 
  1105 
  1274 
  1106 
  1275 !
       
  1276 
       
  1277 getDepthAndSistersNumberOfNode: aNode onParentNode: aParentNode
       
  1278     "return depth of selected node"
       
  1279 
       
  1280     |parent childNode depthAndSistersNumbers str|
       
  1281 
       
  1282     depthAndSistersNumbers := OrderedCollection new.
       
  1283     childNode := aNode.
       
  1284     parent := aParentNode.
       
  1285     [parent notNil] 
       
  1286     whileTrue: 
       
  1287     [
       
  1288         depthAndSistersNumbers add: (parent children indexOf: childNode). 
       
  1289         childNode := parent. 
       
  1290         parent := parent parent. 
       
  1291     ].
       
  1292     depthAndSistersNumbers removeFirst; addFirst: aParentNode children size.
       
  1293     str := ''.
       
  1294     depthAndSistersNumbers reverseDo: [:n| str := str, n printString, '.'].
       
  1295     ^str copyFrom: 1 to: str size - 1
       
  1296 ! !
  1107 ! !
  1297 
  1108 
  1298 !HierarchicalListEditor class methodsFor:'documentation'!
  1109 !HierarchicalListEditor class methodsFor:'documentation'!
  1299 
  1110 
  1300 version
  1111 version