HierarchicalListEditor.st
changeset 736 6db5efc5df90
parent 731 cd36a0c9ba62
child 747 c76003b74d7b
equal deleted inserted replaced
735:29c8681ce68d 736:6db5efc5df90
     1 "
     1 "
     2  COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
     2  COPYRIGHT (c) 1997 by eXept Software AG
     3               All Rights Reserved
     3               All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice. This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 
    14 
    15 
    15 
    16 ListSpecEditor subclass:#HierarchicalListEditor
    16 ResourceSpecEditor subclass:#HierarchicalListEditor
    17 	instanceVariableNames:'treeView'
    17 	instanceVariableNames:'treeView'
    18 	classVariableNames:''
    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'!
    24 
    24 
    25 copyright
    25 copyright
    26 "
    26 "
    27  COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
    27  COPYRIGHT (c) 1997 by eXept Software AG
    28               All Rights Reserved
    28               All Rights Reserved
    29 
    29 
    30  This software is furnished under a license and may be used
    30  This software is furnished under a license and may be used
    31  only in accordance with the terms of that license and with the
    31  only in accordance with the terms of that license and with the
    32  inclusion of the above copyright notice.   This software may not
    32  inclusion of the above copyright notice. This software may not
    33  be provided or otherwise made available to, or used by, any
    33  be provided or otherwise made available to, or used by, any
    34  other person.  No title to or ownership of the software is
    34  other person.  No title to or ownership of the software is
    35  hereby transferred.
    35  hereby transferred.
    36 "
    36 "
    37 
    37 
    79 ! !
    79 ! !
    80 
    80 
    81 !HierarchicalListEditor class methodsFor:'help specs'!
    81 !HierarchicalListEditor class methodsFor:'help specs'!
    82 
    82 
    83 helpSpec
    83 helpSpec
    84     "return a dictionary filled with helpKey -> helptext associations.
    84     "This resource specification was automatically generated
    85      These are used by the activeHelp tool."
    85      by the UIHelpTool of ST/X."
    86 
    86 
    87     "
    87     "Do not manually edit this!! If it is corrupted,
    88     UIHelpTool openOnClass:HierarchicalListEditor    
    88      the UIHelpTool may not be able to read the specification."
    89     "
    89 
    90 
    90     "
    91   ^ super helpSpec addPairsFrom:#(
    91      UIHelpTool openOnClass:HierarchicalListEditor    
       
    92     "
       
    93 
       
    94     <resource: #help>
       
    95 
       
    96     ^super helpSpec addPairsFrom:#(
    92 
    97 
    93 #addChild
    98 #addChild
    94 'Adds a new child item.'
    99 'Adds a new child item.'
    95 
   100 
    96 #addSister
   101 #addSister
   101 
   106 
   102 #fileLoad
   107 #fileLoad
   103 'Opens a dialog for selecting and loading a hierarchical list spec from a class.'
   108 'Opens a dialog for selecting and loading a hierarchical list spec from a class.'
   104 
   109 
   105 #fileNew
   110 #fileNew
   106 'Creates a new hierarchical list.'
   111 'Creates a new hierarchical list. '
   107 
   112 
   108 #fileSave
   113 #fileSave
   109 'Saves current hierarchical list spec.'
   114 'Saves current hierarchical list spec.'
   110 
   115 
   111 #fileSaveAs
   116 #fileSaveAs
   118 ! !
   123 ! !
   119 
   124 
   120 !HierarchicalListEditor class methodsFor:'image specs'!
   125 !HierarchicalListEditor class methodsFor:'image specs'!
   121 
   126 
   122 createChildIcon
   127 createChildIcon
   123     "Generated by the Image Editor"
   128     "This resource specification was automatically generated
   124     "
   129      by the ImageEditor of ST/X."
   125     ImageEditor openOnClass:self andSelector:#createChildIcon
   130 
       
   131     "Do not manually edit this!! If it is corrupted,
       
   132      the ImageEditor may not be able to read the specification."
       
   133 
       
   134     "
       
   135      ImageEditor openOnClass:self andSelector:#createChildIcon
   126     "
   136     "
   127 
   137 
   128     <resource: #image>
   138     <resource: #image>
   129 
   139 
   130     ^Icon
   140     ^Icon
   131         constantNamed:#'HierarchicalListEditor createChildIcon'
   141         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]!
   142         ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@AUUUUP@@A????2@@A????2 @A????0@@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A<3L308@A33L33H@A30L33H@A33L33H@A<3L008@A?????8@C*****(@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@_??@_?? _??0_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8') ; yourself); yourself]!
   133 
   143 
   134 createSisterIcon
   144 createSisterIcon
   135     "Generated by the Image Editor"
   145     "This resource specification was automatically generated
   136     "
   146      by the ImageEditor of ST/X."
   137     ImageEditor openOnClass:self andSelector:#createSisterIcon
   147 
       
   148     "Do not manually edit this!! If it is corrupted,
       
   149      the ImageEditor may not be able to read the specification."
       
   150 
       
   151     "
       
   152      ImageEditor openOnClass:self andSelector:#createSisterIcon
   138     "
   153     "
   139 
   154 
   140     <resource: #image>
   155     <resource: #image>
   141 
   156 
   142     ^Icon
   157     ^Icon
   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]! !
   159         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 
   160 
   146 !HierarchicalListEditor class methodsFor:'interface specs'!
   161 !HierarchicalListEditor class methodsFor:'interface specs'!
   147 
   162 
   148 windowSpec
   163 windowSpec
   149     "this window spec was automatically generated by the ST/X UIPainter"
   164     "This resource specification was automatically generated
   150 
   165      by the UIPainter of ST/X."
   151     "do not manually edit this - the painter/builder may not be able to
   166 
   152      handle the specification if its corrupted."
   167     "Do not manually edit this!! If it is corrupted,
       
   168      the UIPainter may not be able to read the specification."
   153 
   169 
   154     "
   170     "
   155      UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec
   171      UIPainter new openOnClass:HierarchicalListEditor andSelector:#windowSpec
   156      HierarchicalListEditor new openInterface:#windowSpec
   172      HierarchicalListEditor new openInterface:#windowSpec
   157     "
   173      HierarchicalListEditor open
   158     "HierarchicalListEditor open"
   174     "
   159 
   175 
   160     <resource: #canvas>
   176     <resource: #canvas>
   161 
   177 
   162     ^
   178     ^
   163      
   179      
   164        #(#FullSpec
   180        #(#FullSpec
   165           #window: 
   181           #window: 
   166            #(#WindowSpec
   182            #(#WindowSpec
   167               #name: 'Hierarchical List Editor'
   183               #name: 'Hierarchical List Editor'
   168               #layout: #(#LayoutFrame 140 0 249 0 614 0 561 0)
   184               #layout: #(#LayoutFrame 229 0 389 0 703 0 701 0)
   169               #label: 'Hierarchical List Editor'
   185               #label: 'Hierarchical List Editor'
   170               #min: #(#Point 10 10)
   186               #min: #(#Point 10 10)
   171               #max: #(#Point 1160 870)
   187               #max: #(#Point 1160 870)
   172               #bounds: #(#Rectangle 140 249 615 562)
   188               #bounds: #(#Rectangle 229 389 704 702)
   173               #menu: #menu
   189               #menu: #menu
   174               #usePreferredExtent: false
   190               #usePreferredExtent: false
   175           )
   191           )
   176           #component: 
   192           #component: 
   177            #(#SpecCollection
   193            #(#SpecCollection
   205                                #(#SpecCollection
   221                                #(#SpecCollection
   206                                   #collection: 
   222                                   #collection: 
   207                                    #(
   223                                    #(
   208                                      #(#LabelSpec
   224                                      #(#LabelSpec
   209                                         #name: 'nameLabel'
   225                                         #name: 'nameLabel'
   210                                         #layout: #(#AlignmentOrigin 108 0 26 0 1 0.5)
   226                                         #layout: #(#AlignmentOrigin 98 0 26 0 1 0.5)
   211                                         #label: 'Label:'
   227                                         #label: 'Label:'
   212                                         #resizeForLabel: true
   228                                         #resizeForLabel: true
   213                                     )
   229                                     )
   214                                      #(#InputFieldSpec
   230                                      #(#InputFieldSpec
   215                                         #name: 'labelInputField'
   231                                         #name: 'labelInputField'
   216                                         #layout: #(#LayoutFrame 110 0 15 0 -5 1.0 37 0)
   232                                         #layout: #(#LayoutFrame 100 0 15 0 -5 1.0 37 0)
   217                                         #activeHelpKey: #label
   233                                         #activeHelpKey: #label
   218                                         #tabable: true
   234                                         #tabable: true
   219                                         #model: #itemName
   235                                         #model: #itemName
   220                                     )
   236                                     )
   221                                      #(#LabelSpec
   237                                      #(#LabelSpec
   222                                         #name: 'valueLabel'
   238                                         #name: 'valueLabel'
   223                                         #layout: #(#AlignmentOrigin 108 0 52 0 1 0.5)
   239                                         #layout: #(#AlignmentOrigin 98 0 52 0 1 0.5)
   224                                         #activeHelpKey: #contents
   240                                         #activeHelpKey: #contents
   225                                         #label: 'Contents:'
   241                                         #label: 'Contents:'
   226                                         #resizeForLabel: true
   242                                         #resizeForLabel: true
   227                                     )
   243                                     )
   228                                      #(#InputFieldSpec
   244                                      #(#InputFieldSpec
   229                                         #name: 'valueInputField'
   245                                         #name: 'valueInputField'
   230                                         #layout: #(#LayoutFrame 110 0 41 0 -5 1.0 63 0)
   246                                         #layout: #(#LayoutFrame 100 0 41 0 -5 1.0 63 0)
   231                                         #activeHelpKey: #contents
   247                                         #activeHelpKey: #contents
   232                                         #tabable: true
   248                                         #tabable: true
   233                                         #model: #itemValue
   249                                         #model: #itemValue
   234                                         #type: #symbolOrNil
   250                                         #type: #symbolOrNil
   235                                     )
   251                                     )
   259 ! !
   275 ! !
   260 
   276 
   261 !HierarchicalListEditor class methodsFor:'menu specs'!
   277 !HierarchicalListEditor class methodsFor:'menu specs'!
   262 
   278 
   263 menu
   279 menu
   264     "this window spec was automatically generated by the ST/X MenuEditor"
   280     "This resource specification was automatically generated
   265 
   281      by the MenuEditor of ST/X."
   266     "do not manually edit this - the builder may not be able to
   282 
   267      handle the specification if its corrupted."
   283     "Do not manually edit this!! If it is corrupted,
       
   284      the MenuEditor may not be able to read the specification."
   268 
   285 
   269     "
   286     "
   270      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menu
   287      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menu
   271      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menu)) startUp
   288      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menu)) startUp
   272     "
   289     "
   368              #(#MenuItem
   385              #(#MenuItem
   369                 #label: 'History'
   386                 #label: 'History'
   370                 #submenuChannel: #menuHistory
   387                 #submenuChannel: #menuHistory
   371             )
   388             )
   372              #(#MenuItem
   389              #(#MenuItem
       
   390                 #label: 'Settings'
       
   391                 #submenu: 
       
   392                  #(#Menu
       
   393                     
       
   394                      #(
       
   395                        #(#MenuItem
       
   396                           #label: 'Fonts'
       
   397                           #submenuChannel: #menuFont
       
   398                       )
       
   399                     ) nil
       
   400                     nil
       
   401                 )
       
   402             )
       
   403              #(#MenuItem
   373                 #label: 'Help'
   404                 #label: 'Help'
   374                 #startGroup: #right
   405                 #startGroup: #right
   375                 #submenuChannel: #menuHelp
   406                 #submenuChannel: #menuHelp
   376             )
   407             )
   377           ) nil
   408           ) nil
   378           nil
   409           nil
   379       )
   410       )
   380 !
   411 !
   381 
   412 
   382 menuEdit
   413 menuEdit
   383     "this window spec was automatically generated by the ST/X MenuEditor"
   414     "This resource specification was automatically generated
   384 
   415      by the MenuEditor of ST/X."
   385     "do not manually edit this - the builder may not be able to
   416 
   386      handle the specification if its corrupted."
   417     "Do not manually edit this!! If it is corrupted,
       
   418      the MenuEditor may not be able to read the specification."
   387 
   419 
   388     "
   420     "
   389      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuEdit
   421      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuEdit
   390      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuEdit)) startUp
   422      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuEdit)) startUp
   391     "
   423     "
   456           nil
   488           nil
   457       )
   489       )
   458 !
   490 !
   459 
   491 
   460 menuToolbar
   492 menuToolbar
   461     "this window spec was automatically generated by the ST/X MenuEditor"
   493     "This resource specification was automatically generated
   462 
   494      by the MenuEditor of ST/X."
   463     "do not manually edit this - the builder may not be able to
   495 
   464      handle the specification if its corrupted."
   496     "Do not manually edit this!! If it is corrupted,
       
   497      the MenuEditor may not be able to read the specification."
   465 
   498 
   466     "
   499     "
   467      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuToolbar
   500      MenuEditor new openOnClass:HierarchicalListEditor andSelector:#menuToolbar
   468      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuToolbar)) startUp
   501      (Menu new fromLiteralArrayEncoding:(HierarchicalListEditor menuToolbar)) startUp
   469     "
   502     "
   741 
   774 
   742 
   775 
   743 
   776 
   744 !
   777 !
   745 
   778 
   746 buildFromListSpec: aListSpec
   779 buildFromResourceSpec: aListSpec
   747 
   780 
   748     treeView root: aListSpec
   781     treeView root: aListSpec
   749 
   782 
   750 !
   783 !
   751 
   784 
   820         ifTrue:[(treeView isInSelection:1) not] 
   853         ifTrue:[(treeView isInSelection:1) not] 
   821         ifFalse: [false]).
   854         ifFalse: [false]).
   822 
   855 
   823     self valueOfCanCopy value: self valueOfCanCut value.
   856     self valueOfCanCopy value: self valueOfCanCut value.
   824 
   857 
   825     self valueOfCanPaste value: (self class clipboard notNil and:[treeView selectedNode notNil]).
   858     self valueOfCanPaste value: treeView selectedNode notNil & self valueOfCanPaste value.
   826 !
   859 !
   827 
   860 
   828 updateInputFields
   861 updateInputFields
   829     "reload item value into input fields"
   862     "reload item value into input fields"
   830 
   863 
   861 !
   894 !
   862 
   895 
   863 openModalOnTreeItem: aTreeItem
   896 openModalOnTreeItem: aTreeItem
   864     "build a tree from aTreeItem and open it modal"
   897     "build a tree from aTreeItem and open it modal"
   865 
   898 
   866     super openModalOnListSpec: aTreeItem
   899     super openModalOnResourceSpec: aTreeItem
   867 ! !
   900 ! !
   868 
   901 
   869 !HierarchicalListEditor methodsFor:'user actions'!
   902 !HierarchicalListEditor methodsFor:'user actions'!
   870 
   903 
   871 accept
   904 accept
   896 
   929 
   897 doCopy
   930 doCopy
   898     "copy current selected nodes into copy buffer"
   931     "copy current selected nodes into copy buffer"
   899 
   932 
   900     self class clipboard: OrderedCollection new.
   933     self class clipboard: OrderedCollection new.
   901     treeView selectedNodesDo:[:aNode| self class clipboard add: aNode copy]
   934     treeView selectedNodesDo:[:aNode| self class clipboard add: aNode copy].
   902 
   935     self updateChannels
   903 !
   936 !
   904 
   937 
   905 doCreateChild
   938 doCreateChild
   906     "create a child within selected parent"
   939     "create a child within selected parent"
   907 
   940 
   969         modified := true
  1002         modified := true
   970     ]
  1003     ]
   971 !
  1004 !
   972 
  1005 
   973 doNew
  1006 doNew
   974     "remove all items; restart"
  1007     "first do super new; then make a build 
   975 
  1008      of a resource spec containing a root"
   976     self askForModification
  1009 
   977     ifTrue: 
  1010     super doNew ifTrue: [self buildRoot]
   978     [
       
   979         self isStandAlone ifTrue: [specClass := specSelector := nil].
       
   980         self buildRoot
       
   981     ]
       
   982 
  1011 
   983 
  1012 
   984 
  1013 
   985 !
  1014 !
   986 
  1015 
   987 doPaste
  1016 doPaste
   988     "paste after current selected item"
  1017     "paste after current selected item"
   989 
  1018 
   990     self askForItemModification
  1019     (self askForItemModification and: [self class clipboard notNil])
   991     ifTrue:
  1020     ifTrue:
   992     [
  1021     [
   993         |copiedNode|
  1022         |copiedNode|
   994         self class clipboard do:
  1023         self class clipboard do:
   995         [:node|
  1024         [:node|
  1036     code := Character excla asString 
  1065     code := Character excla asString 
  1037             , cls name , ' class methodsFor:' , category storeString
  1066             , cls name , ' class methodsFor:' , category storeString
  1038             , Character excla asString , '\\'
  1067             , Character excla asString , '\\'
  1039 
  1068 
  1040             , specSelector , '\'
  1069             , specSelector , '\'
  1041             , '    "this window spec was automatically generated by the ST/X HierarchicalListEditor"\\'
  1070             , (self class codeGenerationComment replChar:$!! withString:'!!!!')
  1042             , '    "do not manually edit this - the builder may not be able to\'
  1071             , '\\    "\'
  1043             , '     handle the specification if its corrupted."\\'
       
  1044             , '    "\'
       
  1045             , '     HierarchicalListEditor openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
  1072             , '     HierarchicalListEditor openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
  1046             , '    "\'.
  1073             , '    "\'.
  1047 
  1074 
  1048     code := code 
  1075     code := code 
  1049             , '\'
  1076             , '\'