TabListEditor.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3330 76129ae4dadd
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

- All source *.st files are now Unicode UTF8 without BOM
Files are in two groups (fileOut works this way in Smalltalk/X):
- containing a unicode character have "{ Encoding: utf8 }" at the header
- ASCII only are without the header
     1 "
     2  COPYRIGHT (c) 1997 by eXept Software AG
     3               All Rights Reserved
     4 
     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
     7  inclusion of the above copyright notice. This software may not
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    11 "
    12 "{ Package: 'stx:libtool2' }"
    13 
    14 "{ NameSpace: Smalltalk }"
    15 
    16 ResourceSpecEditor subclass:#TabListEditor
    17 	instanceVariableNames:'listOfTabs'
    18 	classVariableNames:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    21 !
    22 
    23 !TabListEditor class methodsFor:'documentation'!
    24 
    25 copyright
    26 "
    27  COPYRIGHT (c) 1997 by eXept Software AG
    28               All Rights Reserved
    29 
    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
    32  inclusion of the above copyright notice. This software may not
    33  be provided or otherwise made available to, or used by, any
    34  other person.  No title to or ownership of the software is
    35  hereby transferred.
    36 "
    37 
    38 
    39 !
    40 
    41 documentation
    42 "
    43     The TabListEditor allows you to create, modify or just inspect
    44     tab lists for tab headers or note books.
    45 
    46     [start with:]
    47         TabItemEditor open
    48 
    49     [see also:]
    50         TabItem
    51         TabView
    52         NoteBookView
    53         UIPainter
    54 
    55     [author:]
    56         Claus Atzkern, eXept Software AG
    57         Thomas Zwick, eXept Software AG
    58 "
    59 
    60 
    61 ! !
    62 
    63 !TabListEditor class methodsFor:'instance creation'!
    64 
    65 openModalOnTabList: aTabList
    66     "Open a TabListEditor modal on aTabList"
    67     "self openModalOnTabList: (Array with: (TabItem label: 'Tab Item 1'))"
    68 
    69     ^self new openModalOnTabList: aTabList
    70 
    71 ! !
    72 
    73 !TabListEditor class methodsFor:'accessing'!
    74 
    75 resourceType
    76     "get the type of resource of the method generated by the TabListEditor"
    77 
    78     ^#tabList
    79 
    80 
    81 
    82 
    83 
    84 
    85 ! !
    86 
    87 !TabListEditor class methodsFor:'aspects'!
    88 
    89 aspects
    90     "get the aspects for the attributes of the tab list components"
    91 
    92     ^#(
    93         label
    94         translateLabel
    95         labelForegroundColor
    96         enabled
    97         editAgument
    98         accessCharacterPosition
    99         shortcutKey
   100         activeHelpKey
   101 
   102         majorKey
   103         minorKey
   104         createNewBuilder
   105 
   106         hasHorizontalScrollBar
   107         hasVerticalScrollBar
   108         miniScrollerHorizontal
   109         miniScrollerVertical
   110     )
   111 
   112 ! !
   113 
   114 !TabListEditor class methodsFor:'help specs'!
   115 
   116 helpSpec
   117     "This resource specification was automatically generated
   118      by the UIHelpTool of ST/X."
   119 
   120     "Do not manually edit this!! If it is corrupted,
   121      the UIHelpTool may not be able to read the specification."
   122 
   123     "
   124      UIHelpTool openOnClass:TabListEditor    
   125     "
   126 
   127     <resource: #help>
   128 
   129     ^ super helpSpec addPairsFrom:#(
   130 
   131 #addTabItem
   132 'Adds a new tab item.'
   133 
   134 #applicationProvidesLabel
   135 'If on, the label''s string is a selector returning a string or bitmap image, which is used as logo in the tab item.'
   136 
   137 #autoHideScrollBars
   138 'ScrollBars should be made invisible dynamically, if there is nothing to scroll.'
   139 
   140 #basicTab
   141 'Define the basic attributes.'
   142 
   143 #canSelect
   144 'Turns on/off whether the tab item is selectable.'
   145 
   146 #canvasTab
   147 'Define an application, which is started if the tab is pressed the first time.'
   148 
   149 #color
   150 'Defines the foreground color of the label. The default color derives from the style sheet.'
   151 
   152 #createNewBuilder
   153 'Create a new builder for the application; the application use its own aspects.'
   154 
   155 #detailTab
   156 'Define the optional/specific attributes.'
   157 
   158 #detailsAccelerator
   159 'Key to be pressed to select the tab item from the keyboard (accelerator key).'
   160 
   161 #detailsAccessCharaterPosition
   162 'Index of the access character position of the textual label (optional).'
   163 
   164 #detailsArgument
   165 'An optional argument stored with the tab item.'
   166 
   167 #fileCreateAspectMethod
   168 'Creates the aspect method for the tab list.'
   169 
   170 #fileLoad
   171 'Opens a dialog for selecting and loading a tab list spec from a class.'
   172 
   173 #fileNew
   174 'Creates a new tab list.'
   175 
   176 #fileSave
   177 'Saves current tab list.'
   178 
   179 #horizontalMiniScroller
   180 'Use a mini-scroller as horizontal scrollbar.'
   181 
   182 #horizontalScroller
   183 'Enable horizontal scrollability.'
   184 
   185 #label
   186 'Label of the tab item.'
   187 
   188 #majorKey
   189 'Name of the class to be started (application if empty); or app-selector returning application instance.'
   190 
   191 #minorKey
   192 'Message sent to the class which returns the window specification (default: #windowSpec).'
   193 
   194 #testPreview
   195 'Turns on/off preview of the tab list.'
   196 
   197 #translateLabel
   198 'If on, the label is translated using the applications language resources.'
   199 
   200 #verticalMiniScroller
   201 'Use a mini-scroller as vertical scrollbar.'
   202 
   203 #verticalScroller
   204 'Enable vertical scrollability.'
   205 
   206 )
   207 ! !
   208 
   209 !TabListEditor class methodsFor:'image specs'!
   210 
   211 newTabItemIcon
   212     <resource: #image>
   213     "This resource specification was automatically generated
   214      by the ImageEditor of ST/X."
   215     "Do not manually edit this!!!! If it is corrupted,
   216      the ImageEditor may not be able to read the specification."
   217     "
   218      ImageEditor openOnClass:self andSelector:#newTabItemIcon"
   219     
   220     ^ Icon constantNamed:#'TabListEditor newTabItemIcon'
   221         ifAbsentPut:[
   222             (Depth2Image new)
   223                 width:22;
   224                 height:22;
   225                 photometric:(#palette);
   226                 bitsPerSample:(#( 2 ));
   227                 samplesPerPixel:(1);
   228                 bits:(ByteArray 
   229                             fromPackedString:'U@@@@EUPUEUUVEUPUF**+EUPUF**+EUPUF**+EUP@F**+@@@EV***UV@F*****+@F KNC*+NF(("H*+@F((BC +EF(("H*+@F(("C*+MF*****+@F"@ H*K@F"""(LK@F"" ("K@F"""(*K@F"" H*K@F*****+HK??????@@@@@@@@@');
   230                 colorMapFromArray:#[ 0 0 0 255 255 255 170 170 170 127 127 127 ];
   231                 mask:((ImageMask new)
   232                             width:22;
   233                             height:22;
   234                             bits:(ByteArray 
   235                                         fromPackedString:'G?<@G?<@G?<@G?<@G?<@???<???<???<???????<???<???<???<???????=???<???????<???????<???<???=');
   236                             yourself);
   237                 yourself
   238         ]
   239 ! !
   240 
   241 !TabListEditor class methodsFor:'interface specs'!
   242 
   243 basicSpec
   244     "This resource specification was automatically generated
   245      by the UIPainter of ST/X."
   246 
   247     "Do not manually edit this!! If it is corrupted,
   248      the UIPainter may not be able to read the specification."
   249 
   250     "
   251      UIPainter new openOnClass:TabListEditor andSelector:#basicSpec
   252      TabListEditor new openInterface:#basicSpec
   253     "
   254 
   255     <resource: #canvas>
   256 
   257     ^ 
   258      #(FullSpec
   259         name: basicSpec
   260         window: 
   261        (WindowSpec
   262           label: 'Basic'
   263           name: 'Basic'
   264           min: (Point 10 10)
   265           max: (Point 1280 1024)
   266           bounds: (Rectangle 0 0 429 240)
   267         )
   268         component: 
   269        (SpecCollection
   270           collection: (
   271            (LabelSpec
   272               label: 'Label:'
   273               name: 'labelLabel'
   274               layout: (AlignmentOrigin 98 0 26 0 1 0.5)
   275               translateLabel: true
   276               resizeForLabel: true
   277             )
   278            (InputFieldSpec
   279               name: 'label'
   280               layout: (LayoutFrame 100 0 15 0 -5 1.0 37 0)
   281               activeHelpKey: label
   282               tabable: true
   283               model: label
   284               group: inputGroup
   285               immediateAccept: true
   286               acceptOnReturn: false
   287               acceptOnTab: false
   288               acceptOnLostFocus: false
   289               acceptChannel: acceptChannel
   290               modifiedChannel: modifiedChannel
   291               acceptOnPointerLeave: false
   292             )
   293            (LabelSpec
   294               label: 'Accelerator:'
   295               name: 'shortcutKeyLabel'
   296               layout: (AlignmentOrigin 98 0 55 0 1 0.5)
   297               translateLabel: true
   298               resizeForLabel: true
   299             )
   300            (InputFieldSpec
   301               name: 'shortcutKey'
   302               layout: (LayoutFrame 100 0 44 0 -5 1.0 66 0)
   303               activeHelpKey: detailsAccelerator
   304               tabable: true
   305               model: shortcutKey
   306               group: inputGroup
   307               type: symbolOrNil
   308               immediateAccept: true
   309               acceptOnReturn: false
   310               acceptOnTab: false
   311               acceptOnLostFocus: false
   312               acceptChannel: acceptChannel
   313               modifiedChannel: modifiedChannel
   314               acceptOnPointerLeave: false
   315             )
   316            (LabelSpec
   317               label: 'Argument:'
   318               name: 'editAgumentLabel'
   319               layout: (AlignmentOrigin 98 0 84 0 1 0.5)
   320               translateLabel: true
   321               resizeForLabel: true
   322             )
   323            (InputFieldSpec
   324               name: 'editAgument'
   325               layout: (LayoutFrame 100 0 73 0 -5 1.0 95 0)
   326               activeHelpKey: detailsArgument
   327               tabable: true
   328               model: editAgument
   329               group: inputGroup
   330               immediateAccept: true
   331               acceptOnReturn: false
   332               acceptOnTab: false
   333               acceptOnLostFocus: false
   334               acceptChannel: acceptChannel
   335               modifiedChannel: modifiedChannel
   336               acceptOnPointerLeave: false
   337             )
   338            (LabelSpec
   339               label: 'Access Character Position:'
   340               name: 'accessCharacterPositionLabel'
   341               layout: (AlignmentOrigin 275 0 113 0 1 0.5)
   342               translateLabel: true
   343               resizeForLabel: true
   344             )
   345            (InputFieldSpec
   346               name: 'accessCharacterPosition'
   347               layout: (LayoutFrame 278 0 103 0 -5 1.0 125 0)
   348               activeHelpKey: detailsAccessCharaterPosition
   349               tabable: true
   350               model: accessCharacterPosition
   351               group: inputGroup
   352               type: number
   353               immediateAccept: true
   354               acceptOnReturn: false
   355               acceptOnTab: false
   356               acceptOnLostFocus: false
   357               acceptChannel: acceptChannel
   358               modifiedChannel: modifiedChannel
   359               acceptOnPointerLeave: false
   360             )
   361            (CheckBoxSpec
   362               label: 'Translate Label '
   363               name: 'translateLabel'
   364               layout: (LayoutFrame 96 0 135 0 308 0 161 0)
   365               activeHelpKey: translateLabel
   366               tabable: true
   367               model: translateLabel
   368               translateLabel: true
   369             )
   370            (CheckBoxSpec
   371               label: 'Application Provides Label '
   372               name: 'CheckBox1'
   373               layout: (LayoutFrame 96 0 161 0 308 0 187 0)
   374               activeHelpKey: applicationProvidesLabel
   375               tabable: true
   376               model: applicationProvidesLabel
   377               translateLabel: true
   378             )
   379            (LabelSpec
   380               label: 'Help Key:'
   381               name: 'activeHelp'
   382               layout: (AlignmentOrigin 98 0 203 0 1 0.5)
   383               translateLabel: true
   384               resizeForLabel: true
   385             )
   386            (InputFieldSpec
   387               name: 'activeHelpKey'
   388               layout: (LayoutFrame 100 0 192 0 -5 1.0 214 0)
   389               activeHelpKey: label
   390               tabable: true
   391               model: activeHelpKey
   392               group: inputGroup
   393               type: symbolOrNil
   394               immediateAccept: true
   395               acceptOnReturn: false
   396               acceptOnTab: false
   397               acceptOnLostFocus: false
   398               acceptChannel: acceptChannel
   399               modifiedChannel: modifiedChannel
   400               acceptOnPointerLeave: false
   401             )
   402            )
   403          
   404         )
   405       )
   406 !
   407 
   408 canvasSpec
   409     "This resource specification was automatically generated
   410      by the UIPainter of ST/X."
   411 
   412     "Do not manually edit this!! If it is corrupted,
   413      the UIPainter may not be able to read the specification."
   414 
   415     "
   416      UIPainter new openOnClass:TabListEditor andSelector:#canvasSpec
   417      TabListEditor new openInterface:#canvasSpec
   418     "
   419 
   420     <resource: #canvas>
   421 
   422     ^ 
   423      #(FullSpec
   424         name: canvasSpec
   425         window: 
   426        (WindowSpec
   427           label: 'Canvas'
   428           name: 'Canvas'
   429           min: (Point 10 10)
   430           max: (Point 1280 1024)
   431           bounds: (Rectangle 0 0 383 220)
   432         )
   433         component: 
   434        (SpecCollection
   435           collection: (
   436            (LabelSpec
   437               label: 'Class Name / Major Key:'
   438               name: 'majorKeyLabel'
   439               layout: (AlignmentOrigin 160 0 26 0 1 0.5)
   440               activeHelpKey: majorKey
   441               translateLabel: true
   442               resizeForLabel: true
   443             )
   444            (InputFieldSpec
   445               name: 'majorKeyField'
   446               layout: (LayoutFrame 161 0 15 0 -5 1.0 37 0)
   447               activeHelpKey: majorKey
   448               tabable: true
   449               model: majorKey
   450               group: inputGroup
   451               type: symbolOrNil
   452               immediateAccept: true
   453               acceptOnReturn: false
   454               acceptOnTab: false
   455               acceptOnLostFocus: false
   456               modifiedChannel: modifiedChannel
   457               acceptOnPointerLeave: false
   458             )
   459            (LabelSpec
   460               label: 'Selector / Minor Key:'
   461               name: 'minorKeyLabel'
   462               layout: (AlignmentOrigin 160 0 55 0 1 0.5)
   463               translateLabel: true
   464               resizeForLabel: true
   465             )
   466            (InputFieldSpec
   467               name: 'minorKeyField'
   468               layout: (LayoutFrame 161 0 44 0 -5 1.0 66 0)
   469               activeHelpKey: majorKey
   470               tabable: true
   471               model: minorKey
   472               group: inputGroup
   473               type: symbolOrNil
   474               immediateAccept: true
   475               acceptOnReturn: false
   476               acceptOnTab: false
   477               acceptOnLostFocus: false
   478               modifiedChannel: modifiedChannel
   479               acceptOnPointerLeave: false
   480             )
   481            (FramedBoxSpec
   482               label: 'Scroll Bars'
   483               name: 'FramedBox'
   484               layout: (LayoutFrame 0 0.0 119 0.0 0 1.0 218 0)
   485               labelPosition: topLeft
   486               translateLabel: true
   487               component: 
   488              (SpecCollection
   489                 collection: (
   490                  (HorizontalPanelViewSpec
   491                     name: 'HorizontalPanel1'
   492                     layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   493                     horizontalLayout: fitSpace
   494                     verticalLayout: fitSpace
   495                     horizontalSpace: 3
   496                     verticalSpace: 3
   497                     component: 
   498                    (SpecCollection
   499                       collection: (
   500                        (ViewSpec
   501                           name: 'Box1'
   502                           component: 
   503                          (SpecCollection
   504                             collection: (
   505                              (CheckBoxSpec
   506                                 label: 'Vertical'
   507                                 name: 'verticalScrollBarCheckBox'
   508                                 layout: (LayoutFrame 0 0.0 3 0 0 1.0 27 0)
   509                                 activeHelpKey: verticalScroller
   510                                 tabable: true
   511                                 model: hasVerticalScrollBar
   512                                 translateLabel: true
   513                               )
   514                              (CheckBoxSpec
   515                                 label: 'Mini'
   516                                 name: 'miniScrollerVerticalCheckBox'
   517                                 layout: (LayoutFrame 0 0.0 32 0 0 1.0 56 0)
   518                                 activeHelpKey: verticalMiniScroller
   519                                 tabable: true
   520                                 model: miniScrollerVertical
   521                                 translateLabel: true
   522                               )
   523                              )
   524                            
   525                           )
   526                           useDefaultExtent: true
   527                         )
   528                        (ViewSpec
   529                           name: 'Box2'
   530                           component: 
   531                          (SpecCollection
   532                             collection: (
   533                              (CheckBoxSpec
   534                                 label: 'Horizontal'
   535                                 name: 'horizontalScrollBarCheckBox'
   536                                 layout: (LayoutFrame 0 0.0 3 0 0 1.0 27 0)
   537                                 activeHelpKey: horizontalScroller
   538                                 tabable: true
   539                                 model: hasHorizontalScrollBar
   540                                 translateLabel: true
   541                               )
   542                              (CheckBoxSpec
   543                                 label: 'Mini'
   544                                 name: 'miniScrollerHorizontalCheckBox'
   545                                 layout: (LayoutFrame 0 0.0 32 0 0 1.0 56 0)
   546                                 activeHelpKey: horizontalMiniScroller
   547                                 tabable: true
   548                                 model: miniScrollerHorizontal
   549                                 translateLabel: true
   550                               )
   551                              )
   552                            
   553                           )
   554                           extent: (Point 113 61)
   555                         )
   556                        (ViewSpec
   557                           name: 'Box3'
   558                           component: 
   559                          (SpecCollection
   560                             collection: (
   561                              (LabelSpec
   562                                 label: 'Auto Hide:'
   563                                 name: 'Label1'
   564                                 layout: (LayoutFrame 0 0.0 6 0 0 1.0 23 0)
   565                                 translateLabel: true
   566                                 resizeForLabel: true
   567                                 adjust: left
   568                               )
   569                              (PopUpListSpec
   570                                 label: 'Default'
   571                                 name: 'PopUpList1'
   572                                 layout: (LayoutFrame 0 0.0 32 0 0 1.0 54 0)
   573                                 activeHelpKey: autoHideScrollBars
   574                                 tabable: true
   575                                 model: autoHideScrollBars
   576                                 menu: 
   577                                (Default
   578                                   On Off
   579                                 )
   580                                 useIndex: true
   581                               )
   582                              )
   583                            
   584                           )
   585                           extent: (Point 113 61)
   586                         )
   587                        )
   588                      
   589                     )
   590                   )
   591                  )
   592                
   593               )
   594             )
   595            (CheckBoxSpec
   596               label: 'Create New Builder'
   597               name: 'createNewBuilder'
   598               layout: (Point 161 75)
   599               activeHelpKey: createNewBuilder
   600               model: createNewBuilder
   601               translateLabel: true
   602             )
   603            )
   604          
   605         )
   606       )
   607 !
   608 
   609 detailSpec
   610     "This resource specification was automatically generated
   611      by the UIPainter of ST/X."
   612 
   613     "Do not manually edit this!! If it is corrupted,
   614      the UIPainter may not be able to read the specification."
   615 
   616     "
   617      UIPainter new openOnClass:TabListEditor andSelector:#detailSpec
   618      TabListEditor new openInterface:#detailSpec
   619     "
   620 
   621     <resource: #canvas>
   622 
   623     ^ 
   624      #(FullSpec
   625         name: detailSpec
   626         window: 
   627        (WindowSpec
   628           label: 'Details'
   629           name: 'Details'
   630           min: (Point 10 10)
   631           max: (Point 1280 1024)
   632           bounds: (Rectangle 0 0 358 107)
   633         )
   634         component: 
   635        (SpecCollection
   636           collection: (
   637            (CheckBoxSpec
   638               label: 'Can Select'
   639               name: 'enabled'
   640               layout: (Point 46 14)
   641               activeHelpKey: canSelect
   642               tabable: true
   643               model: enabled
   644               translateLabel: true
   645             )
   646            (LabelSpec
   647               label: 'Color:'
   648               name: 'ForegroundLabel'
   649               layout: (AlignmentOrigin 46 0 62 0 1 0.5)
   650               translateLabel: true
   651               resizeForLabel: true
   652               adjust: right
   653             )
   654            (ColorMenuSpec
   655               name: 'ForegroundColorMenu'
   656               layout: (LayoutFrame 48 0 50 0 -10 1.0 72 0)
   657               activeHelpKey: color
   658               model: labelForegroundColor
   659               labelsAreColored: false
   660             )
   661            )
   662          
   663         )
   664       )
   665 !
   666 
   667 windowSpec
   668     "This resource specification was automatically generated
   669      by the UIPainter of ST/X."
   670 
   671     "Do not manually edit this!! If it is corrupted,
   672      the UIPainter may not be able to read the specification."
   673 
   674     "
   675      UIPainter new openOnClass:TabListEditor andSelector:#windowSpec
   676      TabListEditor new openInterface:#windowSpec
   677      TabListEditor open
   678     "
   679 
   680     <resource: #canvas>
   681 
   682     ^ 
   683      #(#FullSpec
   684         #name: #windowSpec
   685         #window: 
   686        #(#WindowSpec
   687           #label: 'Tab List Editor'
   688           #name: 'Tab List Editor'
   689           #min: #(#Point 440 280)
   690           #bounds: #(#Rectangle 596 292 1132 661)
   691           #menu: #menu
   692         )
   693         #component: 
   694        #(#SpecCollection
   695           #collection: #(
   696            #(#MenuPanelSpec
   697               #name: 'menuToolbarView'
   698               #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 34 0)
   699               #menu: #menuToolbar
   700               #showSeparatingLines: true
   701             )
   702            #(#VariableHorizontalPanelSpec
   703               #name: 'VariablePanel'
   704               #layout: #(#LayoutFrame 0 0.0 36 0.0 0 1.0 -26 1.0)
   705               #component: 
   706              #(#SpecCollection
   707                 #collection: #(
   708                  #(#SelectionInListModelViewSpec
   709                     #attributes: 
   710                    #(#vpext
   711                       
   712                      #(#Array
   713                         #Array #Array
   714                         #Array #Array
   715                         #Array #Point
   716                         0.264414 1.0
   717                       )
   718                     )
   719                     #name: 'ListOfLabels'
   720                     #tabable: true
   721                     #model: #selectionHolder
   722                     #menu: #menuEdit
   723                     #hasHorizontalScrollBar: true
   724                     #hasVerticalScrollBar: true
   725                     #miniScrollerHorizontal: true
   726                     #listModel: #listOfTabs
   727                     #highlightMode: #line
   728                     #selectConditionSelector: #askForItemModification
   729                   )
   730                  #(#ViewSpec
   731                     #name: 'SpecView'
   732                     #level: -1
   733                     #component: 
   734                    #(#SpecCollection
   735                       #collection: #(
   736                        #(#NoteBookViewSpec
   737                           #name: 'NoteBook'
   738                           #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -30 1.0)
   739                           #enableChannel: #hasSelectionHolder
   740                           #tabable: true
   741                           #model: #noteBookModel
   742                           #menu: #noteBookTabList
   743                           #useIndex: true
   744                           #keepCanvasAlive: true
   745                         )
   746                        #(#UISubSpecification
   747                           #name: 'subSpec'
   748                           #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1)
   749                           #majorKey: #ToolApplicationModel
   750                           #minorKey: #windowSpecForCommit
   751                         )
   752                        #(#NoteBookViewSpec
   753                           #name: 'TestNoteBook'
   754                           #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   755                           #visibilityChannel: #testMode
   756                           #tabable: true
   757                           #menu: #testItemList
   758                           #useIndex: true
   759                         )
   760                        )
   761                      
   762                     )
   763                   )
   764                  )
   765                
   766               )
   767               #handles: #(#Any 0.24053 1.0)
   768             )
   769            #(#UISubSpecification
   770               #name: 'infoBarSubSpec'
   771               #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
   772               #majorKey: #ToolApplicationModel
   773               #minorKey: #windowSpecForInfoBar
   774             )
   775            )
   776          
   777         )
   778       )
   779 ! !
   780 
   781 !TabListEditor class methodsFor:'list specs'!
   782 
   783 noteBookTabList
   784     "This resource specification was automatically generated
   785      by the TabListEditor of ST/X."
   786 
   787     "Do not manually edit this!! If it is corrupted,
   788      the TabListEditor may not be able to read the specification."
   789 
   790     "
   791      TabListEditor new openOnClass:TabListEditor andSelector:#noteBookTabList
   792     "
   793 
   794     <resource: #tabList>
   795 
   796     ^     #(
   797        #(#TabItem
   798           #label: 'Basic'
   799           #activeHelpKey: #basicTab
   800           #minorKey: #basicSpec
   801         )
   802        #(#TabItem
   803           #label: 'Details'
   804           #activeHelpKey: #detailTab
   805           #minorKey: #detailSpec
   806         )
   807        #(#TabItem
   808           #label: 'Canvas'
   809           #activeHelpKey: #canvasTab
   810           #minorKey: #canvasSpec
   811         )
   812        )
   813      
   814       collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]
   815 ! !
   816 
   817 !TabListEditor class methodsFor:'menu specs'!
   818 
   819 menu
   820     "This resource specification was automatically generated
   821      by the MenuEditor of ST/X."
   822 
   823     "Do not manually edit this!! If it is corrupted,
   824      the MenuEditor may not be able to read the specification."
   825 
   826     "
   827      MenuEditor new openOnClass:TabListEditor andSelector:#menu
   828      (Menu new fromLiteralArrayEncoding:(TabListEditor menu)) startUp
   829     "
   830 
   831     <resource: #menu>
   832 
   833     ^
   834      
   835        #(#Menu
   836           
   837            #(
   838              #(#MenuItem
   839                 #label: 'About'
   840                 #activeHelpKey: #about
   841                 #labelImage: #(#ResourceRetriever nil #menuIcon)
   842                 #submenuChannel: #menuAbout
   843             )
   844              #(#MenuItem
   845                 #label: 'File'
   846                 #activeHelpKey: #file
   847                 #submenu: 
   848                  #(#Menu
   849                     
   850                      #(
   851                        #(#MenuItem
   852                           #label: 'New'
   853                           #value: #doNew
   854                           #activeHelpKey: #fileNew
   855                       )
   856                        #(#MenuItem
   857                           #label: '-'
   858                       )
   859                        #(#MenuItem
   860                           #label: 'Load...'
   861                           #translateLabel: true
   862                           #value: #doLoad
   863                           #activeHelpKey: #fileLoad
   864                       )
   865                        #(#MenuItem
   866                           #label: '-'
   867                       )
   868                        #(#MenuItem
   869                           #label: 'Save'
   870                           #value: #doSave
   871                           #activeHelpKey: #fileSave
   872                       )
   873                        #(#MenuItem
   874                           #label: 'Save As...'
   875                           #value: #doSaveAs
   876                           #activeHelpKey: #fileSave
   877                       )
   878                        #(#MenuItem
   879                           #label: '-'
   880                       )
   881                        #(#MenuItem
   882                           #label: 'Browse Class'
   883                           #value: #doBrowseClass
   884                           #activeHelpKey: #fileBrowseClass
   885                       )
   886                        #(#MenuItem
   887                           #label: '-'
   888                       )
   889                        #(#MenuItem
   890                           #label: 'Exit'
   891                           #value: #closeRequest
   892                           #activeHelpKey: #fileExit
   893                       )
   894                     ) nil
   895                     nil
   896                 )
   897             )
   898              #(#MenuItem
   899                 #label: 'Edit'
   900                 #activeHelpKey: #edit
   901                 #submenuChannel: #menuEdit
   902             )
   903              #(#MenuItem
   904                 #label: 'Add'
   905                 #activeHelpKey: #add
   906                 #submenu: 
   907                  #(#Menu
   908                     
   909                      #(
   910                        #(#MenuItem
   911                           #label: 'Tab Item'
   912                           #value: #doCreate
   913                           #activeHelpKey: #addTabItem
   914                           #labelImage: #(#ResourceRetriever nil #newTabItemIcon 'Tab Item')
   915                       )
   916                     ) nil
   917                     nil
   918                 )
   919             )
   920              #(#MenuItem
   921                 #label: 'Generate'
   922                 #activeHelpKey: #add
   923                 #submenu: 
   924                  #(#Menu
   925                     
   926                      #(
   927                        #(#MenuItem
   928                           #label: 'Aspect Method'
   929                           #value: #doGenerateAspectMethod
   930                           #activeHelpKey: #fileCreateAspectMethod
   931                           #enabled: #hasClassAndSelector
   932                       )
   933                     ) nil
   934                     nil
   935                 )
   936             )
   937              #(#MenuItem
   938                 #label: 'Test'
   939                 #activeHelpKey: #test
   940                 #submenu: 
   941                  #(#Menu
   942                     
   943                      #(
   944                        #(#MenuItem
   945                           #label: 'Preview'
   946                           #activeHelpKey: #testPreview
   947                           #enabled: #canToggleTestMode
   948                           #indication: #testMode
   949                       )
   950                     ) nil
   951                     nil
   952                 )
   953             )
   954              #(#MenuItem
   955                 #label: 'History'
   956                 #activeHelpKey: #history
   957                 #submenuChannel: #menuHistory
   958             )
   959              #(#MenuItem
   960                 label: 'MENU_Help'
   961                 #startGroup: #right
   962                 #activeHelpKey: #help
   963                 #submenuChannel: #menuHelp
   964                 startGroup: conditionalRight
   965             )
   966           ) nil
   967           nil
   968       )
   969 !
   970 
   971 menuEdit
   972     "This resource specification was automatically generated
   973      by the MenuEditor of ST/X."
   974 
   975     "Do not manually edit this!! If it is corrupted,
   976      the MenuEditor may not be able to read the specification."
   977 
   978     "
   979      MenuEditor new openOnClass:TabListEditor andSelector:#menuEdit
   980      (Menu new fromLiteralArrayEncoding:(TabListEditor menuEdit)) startUp
   981     "
   982 
   983     <resource: #menu>
   984 
   985     ^ 
   986      #(#Menu
   987         #(
   988          #(#MenuItem
   989             #label: 'Cut'
   990             #value: #doCut
   991             #activeHelpKey: #editCut
   992             #enabled: #hasSelectionHolder
   993           )
   994          #(#MenuItem
   995             #label: 'Copy'
   996             #value: #doCopy
   997             #activeHelpKey: #editCopy
   998             #enabled: #hasSelectionHolder
   999           )
  1000          #(#MenuItem
  1001             #label: 'Paste'
  1002             #value: #doPaste
  1003             #activeHelpKey: #editPaste
  1004             #enabled: #canPasteHolder
  1005           )
  1006          #(#MenuItem
  1007             #label: 'Delete'
  1008             #value: #doDelete
  1009             #activeHelpKey: #editPaste
  1010             #enabled: #hasSelectionHolder
  1011           )
  1012          #(#MenuItem
  1013             #label: '-'
  1014           )
  1015          #(#MenuItem
  1016             #label: 'Move Up'
  1017             #value: #doMoveTabUpOrDown:
  1018             #activeHelpKey: #editMoveUp
  1019             #enabled: #canMoveTabItemUpOrDown
  1020             #argument: #up
  1021             #labelImage: #(#ResourceRetriever #Icon #upIcon 'Move Up')
  1022           )
  1023          #(#MenuItem
  1024             #label: 'Move Down'
  1025             #value: #doMoveTabUpOrDown:
  1026             #activeHelpKey: #editMoveDown
  1027             #enabled: #canMoveTabItemUpOrDown
  1028             #argument: #down
  1029             #labelImage: #(#ResourceRetriever #Icon #downIcon 'Move Down')
  1030           )
  1031          #(#MenuItem
  1032             #label: '-'
  1033             #isVisible: #hiddenAccelerator
  1034           )
  1035          #(#MenuItem
  1036             #label: 'Accept'
  1037             #translateLabel: true
  1038             #isVisible: #hiddenAccelerator
  1039             #value: #accept
  1040             #enabled: #enablingCommitButtonsHolder
  1041           )
  1042          )
  1043         nil
  1044         nil
  1045       )
  1046 !
  1047 
  1048 menuToolbar
  1049     "This resource specification was automatically generated
  1050      by the MenuEditor of ST/X."
  1051 
  1052     "Do not manually edit this!! If it is corrupted,
  1053      the MenuEditor may not be able to read the specification."
  1054 
  1055     "
  1056      MenuEditor new openOnClass:TabListEditor andSelector:#menuToolbar
  1057      (Menu new fromLiteralArrayEncoding:(TabListEditor menuToolbar)) startUp
  1058     "
  1059 
  1060     <resource: #menu>
  1061 
  1062     ^ 
  1063      #(Menu
  1064         (
  1065          (MenuItem
  1066             activeHelpKey: fileNew
  1067             label: 'New'
  1068             itemValue: doNew
  1069             translateLabel: true
  1070             isButton: true
  1071             labelImage: (ResourceRetriever ToolbarIconLibrary new22x22Icon)
  1072           )
  1073          (MenuItem
  1074             activeHelpKey: fileLoad
  1075             label: 'Load'
  1076             itemValue: doLoad
  1077             translateLabel: true
  1078             isButton: true
  1079             labelImage: (ResourceRetriever ToolbarIconLibrary loadFromMethodIcon)
  1080           )
  1081          (MenuItem
  1082             activeHelpKey: fileSave
  1083             label: 'Save'
  1084             itemValue: doSave
  1085             translateLabel: true
  1086             isButton: true
  1087             labelImage: (ResourceRetriever ToolbarIconLibrary saveAsMethodIcon)
  1088           )
  1089          (MenuItem
  1090             label: '-'
  1091           )
  1092          (MenuItem
  1093             activeHelpKey: editCut
  1094             enabled: hasSelectionHolder
  1095             label: 'Cut'
  1096             itemValue: doCut
  1097             translateLabel: true
  1098             isButton: true
  1099             labelImage: (ResourceRetriever ToolbarIconLibrary cutWidgetIcon)
  1100           )
  1101          (MenuItem
  1102             activeHelpKey: editCopy
  1103             enabled: hasSelectionHolder
  1104             label: 'Copy'
  1105             itemValue: doCopy
  1106             translateLabel: true
  1107             isButton: true
  1108             labelImage: (ResourceRetriever ToolbarIconLibrary copyWidgetIcon)
  1109           )
  1110          (MenuItem
  1111             activeHelpKey: editPaste
  1112             enabled: canPasteHolder
  1113             label: 'Paste'
  1114             itemValue: doPaste
  1115             translateLabel: true
  1116             isButton: true
  1117             labelImage: (ResourceRetriever ToolbarIconLibrary pasteWidgetIcon)
  1118           )
  1119          (MenuItem
  1120             activeHelpKey: editDelete
  1121             enabled: hasSelectionHolder
  1122             label: 'Delete'
  1123             itemValue: doDelete
  1124             translateLabel: true
  1125             isButton: true
  1126             isVisible: false
  1127             labelImage: (ResourceRetriever ToolbarIconLibrary delete22x22Icon)
  1128           )
  1129          (MenuItem
  1130             label: '-'
  1131           )
  1132          (MenuItem
  1133             activeHelpKey: addTabItem
  1134             label: 'Add Tab Item'
  1135             itemValue: doCreate
  1136             translateLabel: true
  1137             isButton: true
  1138             labelImage: (ResourceRetriever nil newTabItemIcon)
  1139           )
  1140          (MenuItem
  1141             label: ''
  1142           )
  1143          (MenuItem
  1144             activeHelpKey: editMoveUp
  1145             enabled: canMoveTabItemUpOrDown
  1146             label: 'Move Tab Up'
  1147             itemValue: doMoveTabUpOrDown:
  1148             translateLabel: true
  1149             isButton: true
  1150             startGroup: right
  1151             labelImage: (ResourceRetriever XPToolbarIconLibrary up22x22Icon)
  1152             argument: up
  1153           )
  1154          (MenuItem
  1155             activeHelpKey: editMoveDown
  1156             enabled: canMoveTabItemUpOrDown
  1157             label: 'Move Tab Down'
  1158             itemValue: doMoveTabUpOrDown:
  1159             translateLabel: true
  1160             isButton: true
  1161             startGroup: right
  1162             labelImage: (ResourceRetriever XPToolbarIconLibrary down22x22Icon)
  1163             argument: down
  1164           )
  1165          )
  1166         nil
  1167         nil
  1168       )
  1169 ! !
  1170 
  1171 !TabListEditor methodsFor:'aspects'!
  1172 
  1173 autoHideScrollBars
  1174     |holder|
  1175 
  1176     (holder := builder bindingAt:#autoHideScrollBars) isNil ifTrue:[
  1177         builder aspectAt:#autoHideScrollBars put:(holder := 1 asValue).
  1178         holder addDependent: self
  1179     ].
  1180     ^ holder.
  1181 !
  1182 
  1183 canMoveTabItemUpOrDown
  1184     ^ builder booleanValueAspectFor:#canMoveTabItemUpOrDown
  1185 !
  1186 
  1187 hasSelectionHolder
  1188     ^ builder booleanValueAspectFor:#hasSelectionHolder
  1189 !
  1190 
  1191 hiddenAccelerator
  1192     "used to set menu entries with an accelerator not visible to the operator
  1193     "
  1194     ^ false
  1195 !
  1196 
  1197 inputGroup
  1198 
  1199     |holder|
  1200 
  1201     (holder := builder bindingAt:#inputGroup) isNil ifTrue:[
  1202         builder aspectAt:#inputGroup put:(holder := EnterFieldGroup new)
  1203     ].
  1204     ^ holder.
  1205 
  1206 
  1207 !
  1208 
  1209 listOfTabs
  1210     ^ listOfTabs
  1211 !
  1212 
  1213 noteBookModel
  1214     |holder|
  1215 
  1216     (holder := builder bindingAt:#noteBookModel) isNil ifTrue:[
  1217         holder := 0 asValue.
  1218         builder aspectAt:#noteBookModel put:holder.
  1219     ].
  1220     ^ holder.
  1221 !
  1222 
  1223 noteBookTabList
  1224     "Generated by the TabListEditor"
  1225 
  1226     |list|
  1227 
  1228     (list := builder bindingAt:#noteBookTabList) isNil ifTrue:[
  1229         builder aspectAt:#noteBookTabList put:(list := self class noteBookTabList).
  1230     ].
  1231     ^ list
  1232 !
  1233 
  1234 selectionHolder
  1235     "holder which keeps the current selection
  1236     "
  1237     |holder|
  1238 
  1239     (holder := builder bindingAt:#selectionHolder) isNil ifTrue:[
  1240         holder := 0 asValue.
  1241         builder aspectAt:#selectionHolder put:holder.
  1242         holder addDependent:self.
  1243     ].
  1244     ^ holder
  1245 !
  1246 
  1247 testItemList
  1248     |holder|
  1249 
  1250     (holder := builder bindingAt:#testItemList) isNil ifTrue:[
  1251         holder := ValueHolder new.
  1252         builder aspectAt:#testItemList put:holder.
  1253     ].
  1254     ^ holder.
  1255 !
  1256 
  1257 testMode
  1258 
  1259     |holder|
  1260 
  1261     (holder := builder bindingAt:#testMode) isNil ifTrue:[
  1262         builder aspectAt:#testMode put:(holder := false asValue).
  1263         holder addDependent: self
  1264     ].
  1265     ^ holder
  1266 
  1267 ! !
  1268 
  1269 !TabListEditor methodsFor:'building'!
  1270 
  1271 buildFromResourceSpec:aListSpec
  1272     self buildFromTabList:aListSpec
  1273 !
  1274 
  1275 buildFromTabList: aTabList
  1276     "build from a aTabList"
  1277 
  1278     self selection:0.
  1279     listOfTabs removeAll.
  1280 
  1281     aTabList do:[:aTabItem| 
  1282         self assert:(aTabItem isKindOf:TabItem).
  1283         listOfTabs add: aTabItem 
  1284     ].
  1285     self clearModified.
  1286     listOfTabs notEmpty ifTrue:[ self selection:1 ].
  1287 
  1288     "Modified: / 08-11-2010 / 13:57:27 / cg"
  1289 !
  1290 
  1291 loadFromClass:aClass andSelector:aSelector
  1292     "build from class and selector"
  1293 
  1294     |cls spec|
  1295 
  1296     self assert:(aClass isNil or:[aClass isClass]).
  1297 
  1298     self testMode value: false.
  1299     self selection:0.
  1300 
  1301     "if opened on a tab list"
  1302     (aClass isNil and: [aSelector isNil and: [listOfTabs size > 0]]) ifFalse:[
  1303         listOfTabs removeAll.
  1304 
  1305         cls := aClass isBehavior ifTrue:[ aClass ] ifFalse:[ self resolveName:aClass].
  1306         specSelector := aSelector.
  1307 
  1308         cls notNil ifTrue:[
  1309             specSelector notNil ifTrue:[
  1310 
  1311                 (cls respondsTo: aSelector) ifTrue:[ 
  1312                     spec := cls perform: aSelector.
  1313                 ].
  1314                 spec size ~~ 0 ifTrue:[
  1315                     spec do:[:aTabOrArray|
  1316                         |tab|
  1317 
  1318                         aTabOrArray isArray ifTrue:[  
  1319                             tab := aTabOrArray decodeAsLiteralArray
  1320                         ] ifFalse:[
  1321                             tab := aTabOrArray.
  1322                         ].
  1323                         self assert:(tab isKindOf:TabItem).
  1324                         listOfTabs add:tab.
  1325                     ].
  1326                     self addHistoryEntryForClass:cls selector:specSelector.
  1327                 ]
  1328             ]
  1329         ].
  1330 
  1331         self clearModified.
  1332     ].
  1333     listOfTabs notEmpty ifTrue:[ self selection:1 ].
  1334 
  1335     "Modified: / 08-11-2010 / 13:59:09 / cg"
  1336 ! !
  1337 
  1338 !TabListEditor methodsFor:'change & update'!
  1339 
  1340 update:something with:aParameter from:someObject
  1341     "one of my aspects has changed; update modified channel
  1342     "
  1343     |list|
  1344 
  1345     someObject = self selectionHolder ifTrue:[
  1346         ^ self selectionChanged
  1347     ].
  1348 
  1349     someObject = self testMode ifFalse:[              
  1350         ^ super update:something with:aParameter from:someObject.
  1351     ].
  1352 
  1353     someObject value ifTrue:[
  1354         self noteBookModel value:0.
  1355 
  1356         listOfTabs notEmpty ifTrue:[
  1357             list := listOfTabs collect:[:aTab| |tab|
  1358                 tab := aTab copy.
  1359                 tab setAttributesFromClass:specClass.
  1360                 tab
  1361             ]
  1362         ].
  1363         self selection:0.
  1364     ].
  1365     self testItemList value:list.
  1366     self updateInfoLabel.
  1367 
  1368 ! !
  1369 
  1370 !TabListEditor methodsFor:'queries'!
  1371 
  1372 canToggleTestMode
  1373     "checks whether testMode button is enabled"
  1374 
  1375     self testMode value ifTrue:[
  1376         ^ true
  1377     ].
  1378 
  1379     self enablingCommitButtonsHolder value ifFalse:[
  1380         ^ listOfTabs notEmpty
  1381     ].
  1382     ^ false
  1383 ! !
  1384 
  1385 !TabListEditor methodsFor:'selection'!
  1386 
  1387 selectedElement
  1388     |idx tab|
  1389 
  1390     idx := self selection.
  1391 
  1392     idx ~~ 0 ifTrue:[
  1393         (tab := listOfTabs at:idx ifAbsent:nil) notNil ifTrue:[
  1394             ^ tab
  1395         ].
  1396         self selection:0
  1397     ].
  1398     ^ nil
  1399 !
  1400 
  1401 selection
  1402     ^ self selectionHolder value ? 0
  1403 !
  1404 
  1405 selection:anIndex
  1406     self selectionHolder value:(anIndex ? 0).
  1407 !
  1408 
  1409 selectionChanged
  1410     |noteBookModel hasSelection|
  1411 
  1412     hasSelection  := self selection ~~ 0.
  1413     noteBookModel := self noteBookModel.
  1414 
  1415     hasSelection ifTrue:[
  1416         self testMode value:false.
  1417         noteBookModel value == 0 ifTrue:[noteBookModel value:1]
  1418     ] ifFalse:[
  1419         noteBookModel value:0
  1420     ].
  1421     self cancel.
  1422     self hasSelectionHolder value:hasSelection.
  1423     self canPasteHolder.
  1424 !
  1425 
  1426 setSelection:anIndex
  1427     |index|
  1428 
  1429     index := anIndex ? 0.
  1430     self selectionHolder value:index withoutNotifying:self
  1431 ! !
  1432 
  1433 !TabListEditor methodsFor:'startup & release'!
  1434 
  1435 initialize
  1436     "setup aspects used by column description specifications
  1437     "
  1438     super initialize.
  1439     listOfTabs := List new.
  1440 !
  1441 
  1442 openModalOnTabList: aTabList
  1443     "build a tab list from aTabList and open it modal"
  1444 
  1445     super openModalOnResourceSpec: aTabList
  1446 
  1447 ! !
  1448 
  1449 !TabListEditor methodsFor:'user actions'!
  1450 
  1451 accept
  1452     "accept changes
  1453     "
  1454     |tab asb|
  1455 
  1456     (tab := self selectedElement) notNil ifTrue:[
  1457         super accept.
  1458         aspects keysAndValuesDo:[:k :m| tab perform:k asMutator with:(m value) ].
  1459 
  1460         asb := self autoHideScrollBars value.
  1461         asb := asb ~~ 1 ifTrue:[asb == 2] ifFalse:[nil].
  1462         tab autoHideScrollBars:asb.
  1463     ].
  1464     self cancel.
  1465 !
  1466 
  1467 addTab:aTab
  1468     |idx|
  1469 
  1470     aTab notNil ifTrue:[
  1471         self assert:(aTab isKindOf:TabItem).
  1472         self testMode value: false.
  1473 
  1474         (idx := self selection) == 0 ifTrue:[
  1475             listOfTabs add:aTab.
  1476             self selection:(listOfTabs size).
  1477         ] ifFalse:[
  1478             listOfTabs add:aTab afterIndex:idx
  1479         ].
  1480         self setModified.
  1481     ].
  1482 
  1483     "Modified: / 08-11-2010 / 13:55:27 / cg"
  1484 !
  1485 
  1486 cancel
  1487     "cancel all changes"
  1488 
  1489     |tab idx asb|
  1490 
  1491     (     (idx := self selection) ~~ 0
  1492      and:[(tab := self selectedElement) notNil]
  1493     ) ifTrue:[
  1494         aspects keysAndValuesDo:[:k :m| m value:(tab perform:k) ].
  1495         listOfTabs at:idx put:tab.
  1496 
  1497         asb := tab autoHideScrollBars.
  1498         asb notNil ifTrue:[asb := asb == true ifTrue:[2] ifFalse:[3]]
  1499                   ifFalse:[asb := 1].
  1500 
  1501         self autoHideScrollBars value:asb.
  1502     ].
  1503     self canMoveTabItemUpOrDown value:(listOfTabs size > 1 and:[idx ~~ 0]).
  1504     self enablingCommitButtonsHolder value: false
  1505 !
  1506 
  1507 doCopy
  1508     "copy selected tab
  1509     "
  1510     |tab|
  1511 
  1512     (tab := self selectedElement) notNil ifTrue:[
  1513         self clipboard:tab.
  1514         self updateAllToolInstances.
  1515     ]
  1516 !
  1517 
  1518 doCreate
  1519     self addTab:(TabItem label:'TAB').
  1520 !
  1521 
  1522 doCut
  1523     "cut the selected tab; put to pasteBuffer
  1524     "
  1525     |tab|
  1526 
  1527     (tab := self selectedElement) notNil ifTrue:[
  1528         self clipboard:tab.
  1529         self doDelete.
  1530     ].
  1531 
  1532 !
  1533 
  1534 doDelete
  1535     "delete selected tab
  1536     "
  1537     |index size|
  1538 
  1539     (index := self selection) ~~ 0 ifTrue:[
  1540         self testMode value: false.
  1541 
  1542         (size := listOfTabs size) == 1 ifTrue:[
  1543             self selection:0
  1544         ] ifFalse:[
  1545             self setSelection:0
  1546         ].
  1547         listOfTabs removeIndex:index.
  1548         index < size ifFalse:[
  1549             index := index - 1
  1550         ].
  1551         self selection:index.
  1552         self updateAllToolInstances.
  1553         self setModified.
  1554     ].       
  1555 !
  1556 
  1557 doGenerateAspectMethod
  1558     "generate aspect method
  1559     "
  1560     |cls code|
  1561 
  1562     (specClass notNil and:[specSelector notNil])
  1563     ifFalse:
  1564     [
  1565         ^self information:'No class and selector defined!!'   
  1566     ].
  1567 
  1568     cls := self resolveName: specClass.
  1569 
  1570     (cls canUnderstand:specSelector) ifTrue:[
  1571         "/ method already exists, do not overwrite the method automaticaly
  1572 
  1573         ( YesNoBox title:'method '
  1574                          , (Text string:('#', specSelector) emphasis:#bold)
  1575                          , ' already exists!!'
  1576                  yesText:'overwrite'
  1577                   noText:'cancel'
  1578         ) confirm ifFalse:[
  1579             ^ self
  1580         ]
  1581     ].
  1582 
  1583     code := '!!' , cls name , ' methodsFor:''aspects''!!\\' ,
  1584             specSelector , '\' ,
  1585             '    "Generated by the TabListEditor"\' ,
  1586             '\' ,
  1587             '    |list|\' ,
  1588             '\' ,
  1589             '    (list := builder bindingAt:#' , specSelector , ') isNil ifTrue:[\' ,
  1590             '        builder aspectAt:#' , specSelector, ' put:(list := self class ', specSelector, ').\' ,
  1591             '    ].\' ,
  1592             '    ^ list\' ,
  1593             '!! !!\\'.
  1594 
  1595     Class packageQuerySignal answer:cls package do:[
  1596         (ReadStream on:(code withCRs)) fileIn
  1597     ]
  1598 
  1599     "Modified: / 28-01-2014 / 21:57:09 / cg"
  1600 !
  1601 
  1602 doMoveTabUpOrDown:what
  1603     "step up or down
  1604     "
  1605     |tab idx sz|
  1606 
  1607     (listOfTabs size > 1 and:[(idx := self selection) ~~ 0]) ifFalse:[
  1608         ^ self
  1609     ].
  1610 
  1611     (tab := listOfTabs at:idx ifAbsent:nil) isNil ifTrue:[
  1612         ^ self selection:0
  1613     ].
  1614 
  1615     self setSelection:0.
  1616     listOfTabs removeIndex:idx.
  1617 
  1618     sz := listOfTabs size.
  1619 
  1620     what == #down ifTrue:[
  1621         idx := idx > sz ifTrue:[1] ifFalse:[idx + 1]
  1622     ] ifFalse:[
  1623         idx := idx == 1 ifTrue:[sz + 1] ifFalse:[idx - 1]
  1624     ].
  1625 
  1626     listOfTabs add:tab beforeIndex:idx.
  1627     self setSelection:idx.
  1628     self setModified.
  1629 !
  1630 
  1631 doPaste
  1632     "paste a tab
  1633     "
  1634     |tab|
  1635 
  1636     ((tab := self class clipboard) notNil and:[tab isKindOf:TabItem]) ifTrue:[
  1637         self addTab:(tab deepCopy).
  1638     ]
  1639 !
  1640 
  1641 doSave
  1642     "generate code for class and instance"
  1643 
  1644     |cls code spec category package mthd list|
  1645 
  1646     (specClass notNil and:[specSelector notNil]) ifFalse:[
  1647         ^ self doSaveAs
  1648     ].
  1649 
  1650     cls := self resolveName: specClass.
  1651 
  1652     listOfTabs isEmpty ifTrue:[^self information:'No tab list defined!!'].
  1653 
  1654     spec  := WriteStream on:''.
  1655     list := Array new:(listOfTabs size).
  1656     listOfTabs keysAndValuesDo:[:i :el|list at:i put:(el literalArrayEncoding)].
  1657 
  1658     UISpecification prettyPrintSpecArray:list on:spec indent:5.
  1659     spec := spec contents.
  1660 
  1661     "/ if that method already exists, do not overwrite the category
  1662 
  1663     category := 'list specs'.
  1664 
  1665     (mthd := cls class compiledMethodAt:specSelector) notNil ifTrue:[
  1666         category := mthd category.
  1667         package := mthd package.
  1668     ].
  1669 
  1670     code := Character excla asString 
  1671             , cls name , ' class methodsFor:' , category storeString
  1672             , Character excla asString , '\\'
  1673 
  1674             , specSelector , '\'
  1675             , (self class codeGenerationComment replChar:$!! withString:'!!!!')
  1676             , '\\    "\'
  1677             , '     TabListEditor new openOnClass: self andSelector:#' , specSelector , '\'
  1678             , '    "\'.
  1679 
  1680     code := code 
  1681             , '\'
  1682             , '    <resource: #tabList>\\'
  1683             , '    ^' 
  1684             , '     ', spec, '\'
  1685             , '      collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]'
  1686             , '\'
  1687             , Character excla asString
  1688             , ' '
  1689             , Character excla asString
  1690             , '\'.
  1691 
  1692     code := code withCRs.
  1693     Class packageQuerySignal 
  1694         answer:package
  1695         do:[
  1696             Class packageQuerySignal answer:cls package do:[
  1697                 (ReadStream on:code) fileIn.
  1698             ].
  1699             (cls canUnderstand:specSelector) ifFalse:[
  1700                 (YesNoBox confirm:(resources string:'Generate aspect method for tabList (#%1)?' with:specSelector)) ifTrue:[
  1701                     self doGenerateAspectMethod
  1702                 ]
  1703             ].
  1704         ].
  1705 
  1706     self addHistoryEntryForClass:cls selector:specSelector.
  1707     self clearModified.
  1708     hasSaved  := true.
  1709 
  1710     "Modified: / 28-01-2014 / 21:56:54 / cg"
  1711 !
  1712 
  1713 openDocumentation
  1714    self openHTMLDocument:'tools/uipainter/TabListEditor.html'.
  1715 ! !
  1716 
  1717 !TabListEditor class methodsFor:'documentation'!
  1718 
  1719 version
  1720     ^ '$Header$'
  1721 !
  1722 
  1723 version_CVS
  1724     ^ '$Header$'
  1725 ! !
  1726