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