TabListEditor.st
changeset 739 cc3413fc1afb
child 749 8f8767c6f32f
equal deleted inserted replaced
738:ebc4a399f4dc 739:cc3413fc1afb
       
     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 
       
    13 
       
    14 
       
    15 ResourceSpecEditor subclass:#TabListEditor
       
    16 	instanceVariableNames:'rebuildMode testView listOfTabs selectedIndex'
       
    17 	classVariableNames:''
       
    18 	poolDictionaries:''
       
    19 	category:'Interface-UIPainter'
       
    20 !
       
    21 
       
    22 !TabListEditor class methodsFor:'documentation'!
       
    23 
       
    24 copyright
       
    25 "
       
    26  COPYRIGHT (c) 1997 by eXept Software AG
       
    27               All Rights Reserved
       
    28 
       
    29  This software is furnished under a license and may be used
       
    30  only in accordance with the terms of that license and with the
       
    31  inclusion of the above copyright notice. This software may not
       
    32  be provided or otherwise made available to, or used by, any
       
    33  other person.  No title to or ownership of the software is
       
    34  hereby transferred.
       
    35 "
       
    36 
       
    37 
       
    38 !
       
    39 
       
    40 documentation
       
    41 "
       
    42     The TabListEditor allows you to create, modify or just inspect
       
    43     tab lists for tab headers or note books.
       
    44 
       
    45     [start with:]
       
    46         TabItemEditor open
       
    47 
       
    48     [see also:]
       
    49         TabItem
       
    50         TabView
       
    51         NoteBookView
       
    52         UIPainter
       
    53 
       
    54     [author:]
       
    55         Claus Atzkern, eXept Software AG
       
    56 "
       
    57 
       
    58 
       
    59 ! !
       
    60 
       
    61 !TabListEditor class methodsFor:'instance creation'!
       
    62 
       
    63 openModalOnTabList: aTabList
       
    64     "Open a TabListEditor modal on aTabList"
       
    65     "self openModalOnTabList: (Array with: (TabItem label: 'Tab Item 1'))"
       
    66 
       
    67     ^self new openModalOnTabList: aTabList
       
    68 
       
    69 ! !
       
    70 
       
    71 !TabListEditor class methodsFor:'accessing'!
       
    72 
       
    73 resourceType
       
    74     "get the type of resource of the method generated by the TabListEditor"
       
    75 
       
    76     ^#tabList
       
    77 
       
    78 
       
    79 
       
    80 
       
    81 
       
    82 
       
    83 ! !
       
    84 
       
    85 !TabListEditor class methodsFor:'aspects'!
       
    86 
       
    87 aspects
       
    88     "get the aspects for the attributes of the tab list components"
       
    89 
       
    90     ^#(
       
    91         label
       
    92         translateLabel
       
    93         labelForegroundColor
       
    94         enabled
       
    95         editAgument
       
    96     )
       
    97 
       
    98 ! !
       
    99 
       
   100 !TabListEditor class methodsFor:'help specs'!
       
   101 
       
   102 helpSpec
       
   103     "This resource specification was automatically generated
       
   104      by the UIHelpTool of ST/X."
       
   105 
       
   106     "Do not manually edit this!! If it is corrupted,
       
   107      the UIHelpTool may not be able to read the specification."
       
   108 
       
   109     "
       
   110      UIHelpTool openOnClass:TabListEditor    
       
   111     "
       
   112 
       
   113     <resource: #help>
       
   114 
       
   115     ^super helpSpec addPairsFrom:#(
       
   116 
       
   117 #addTabItem
       
   118 'Adds a new tab item.'
       
   119 
       
   120 #argument
       
   121 'An argument not explicitly used by the tab item.'
       
   122 
       
   123 #canSelect
       
   124 'Turns on/off whether the tab item is selectable.'
       
   125 
       
   126 #color
       
   127 'Defines the foreground color of the label. The default color derives from the style sheet.'
       
   128 
       
   129 #fileCreateAspectMethod
       
   130 'Creates the aspect method for the tab list.'
       
   131 
       
   132 #fileLoad
       
   133 'Opens a dialog for selecting and loading a tab list spec from a class.'
       
   134 
       
   135 #fileNew
       
   136 'Creates a new tab list.'
       
   137 
       
   138 #fileSave
       
   139 'Saves current tab list.'
       
   140 
       
   141 #label
       
   142 'Label of the tab item.'
       
   143 
       
   144 #labelDerivesFromApplication
       
   145 'If turned on, the label''s string is a selector returning a string or bitmap image, which is used as logo in the tab item.'
       
   146 
       
   147 #testPreview
       
   148 'Turns on/off preview of the tab list.'
       
   149 
       
   150 )
       
   151 ! !
       
   152 
       
   153 !TabListEditor class methodsFor:'image specs'!
       
   154 
       
   155 newTabItemIcon
       
   156     "This resource specification was automatically generated
       
   157      by the ImageEditor of ST/X."
       
   158 
       
   159     "Do not manually edit this!!!! If it is corrupted,
       
   160      the ImageEditor may not be able to read the specification."
       
   161 
       
   162     "
       
   163      ImageEditor openOnClass:self andSelector:#newTabItemIcon
       
   164     "
       
   165 
       
   166     <resource: #image>
       
   167 
       
   168     ^Icon
       
   169         constantNamed:#'TabListEditor newTabItemIcon'
       
   170         ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray 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??????@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 127 127 127]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'G?<@G?<@G?<@G?<@G?<@???<???<???<???????<???<???<???<???????=???<???????<???????<???<???=') ; yourself); yourself]! !
       
   171 
       
   172 !TabListEditor class methodsFor:'interface specs'!
       
   173 
       
   174 tabSpec
       
   175     "This resource specification was automatically generated
       
   176      by the UIPainter of ST/X."
       
   177 
       
   178     "Do not manually edit this!! If it is corrupted,
       
   179      the UIPainter may not be able to read the specification."
       
   180 
       
   181     "
       
   182      UIPainter new openOnClass:TabListEditor andSelector:#tabSpec
       
   183      TabListEditor new openInterface:#tabSpec
       
   184     "
       
   185 
       
   186     <resource: #canvas>
       
   187 
       
   188     ^
       
   189      
       
   190        #(#FullSpec
       
   191           #window: 
       
   192            #(#WindowSpec
       
   193               #name: 'Tab Basic'
       
   194               #layout: #(#LayoutFrame 463 0 289 0 825 0 514 0)
       
   195               #label: 'Tab Basic'
       
   196               #min: #(#Point 10 10)
       
   197               #max: #(#Point 1280 1024)
       
   198               #bounds: #(#Rectangle 463 289 826 515)
       
   199               #usePreferredExtent: false
       
   200           )
       
   201           #component: 
       
   202            #(#SpecCollection
       
   203               #collection: 
       
   204                #(
       
   205                  #(#LabelSpec
       
   206                     #name: 'Label'
       
   207                     #layout: #(#AlignmentOrigin 98 0 26 0 1 0.5)
       
   208                     #label: 'Label:'
       
   209                     #resizeForLabel: true
       
   210                 )
       
   211                  #(#InputFieldSpec
       
   212                     #name: 'LabelField'
       
   213                     #layout: #(#LayoutFrame 100 0 15 0 -5 1.0 37 0)
       
   214                     #activeHelpKey: #label
       
   215                     #model: #label
       
   216                 )
       
   217                  #(#CheckBoxSpec
       
   218                     #name: 'TranslateLabel'
       
   219                     #layout: #(#LayoutFrame 100 0 40 0 -5 1 66 0)
       
   220                     #activeHelpKey: #labelDerivesFromApplication
       
   221                     #model: #translateLabel
       
   222                     #label: 'Label derives from Application'
       
   223                 )
       
   224                  #(#LabelSpec
       
   225                     #name: 'ArgumentLabel'
       
   226                     #layout: #(#AlignmentOrigin 98 0 81 0 1 0.5)
       
   227                     #label: 'Argument:'
       
   228                     #resizeForLabel: true
       
   229                 )
       
   230                  #(#InputFieldSpec
       
   231                     #name: 'ArgumentField'
       
   232                     #layout: #(#LayoutFrame 100 0 70 0 -5 1.0 92 0)
       
   233                     #activeHelpKey: #argument
       
   234                     #model: #editAgument
       
   235                 )
       
   236                  #(#LabelSpec
       
   237                     #name: 'ForegroundLabel'
       
   238                     #layout: #(#AlignmentOrigin 98 0 115 0 1 0.5)
       
   239                     #label: 'Color:'
       
   240                     #adjust: #right
       
   241                     #resizeForLabel: true
       
   242                 )
       
   243                  #(#ColorMenuSpec
       
   244                     #name: 'ForegroundColorMenu'
       
   245                     #layout: #(#LayoutFrame 100 0 103 0 -5 1.0 125 0)
       
   246                     #activeHelpKey: #color
       
   247                     #model: #labelForegroundColor
       
   248                     #labelsAreColored: false
       
   249                 )
       
   250                  #(#CheckBoxSpec
       
   251                     #name: 'CanSelect'
       
   252                     #layout: #(#LayoutFrame 100 0 135 0 -5 1 157 0)
       
   253                     #activeHelpKey: #canSelect
       
   254                     #model: #enabled
       
   255                     #label: 'Can Select'
       
   256                 )
       
   257               )
       
   258           )
       
   259       )
       
   260 !
       
   261 
       
   262 windowSpec
       
   263     "This resource specification was automatically generated
       
   264      by the UIPainter of ST/X."
       
   265 
       
   266     "Do not manually edit this!! If it is corrupted,
       
   267      the UIPainter may not be able to read the specification."
       
   268 
       
   269     "
       
   270      UIPainter new openOnClass:TabListEditor andSelector:#windowSpec
       
   271      TabListEditor new openInterface:#windowSpec
       
   272      TabListEditor open
       
   273     "
       
   274 
       
   275     <resource: #canvas>
       
   276 
       
   277     ^
       
   278      
       
   279        #(#FullSpec
       
   280           #window: 
       
   281            #(#WindowSpec
       
   282               #name: 'Tab List Editor'
       
   283               #layout: #(#LayoutFrame 516 0 302 0 984 0 630 0)
       
   284               #label: 'Tab List Editor'
       
   285               #min: #(#Point 10 10)
       
   286               #max: #(#Point 1152 900)
       
   287               #bounds: #(#Rectangle 516 302 985 631)
       
   288               #menu: #menu
       
   289               #usePreferredExtent: false
       
   290           )
       
   291           #component: 
       
   292            #(#SpecCollection
       
   293               #collection: 
       
   294                #(
       
   295                  #(#MenuPanelSpec
       
   296                     #name: 'menuToolbarView'
       
   297                     #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 34 0)
       
   298                     #menu: #menuToolbar
       
   299                     #showSeparatingLines: true
       
   300                 )
       
   301                  #(#VariableHorizontalPanelSpec
       
   302                     #name: 'VariablePanel'
       
   303                     #layout: #(#LayoutFrame 0 0.0 36 0.0 0 1.0 -26 1.0)
       
   304                     #component: 
       
   305                      #(#SpecCollection
       
   306                         #collection: 
       
   307                          #(
       
   308                            #(#SequenceViewSpec
       
   309                               #name: 'ColumnView'
       
   310                               #model: #selectionHolder
       
   311                               #menu: #menuEdit
       
   312                               #hasHorizontalScrollBar: true
       
   313                               #hasVerticalScrollBar: true
       
   314                               #miniScrollerHorizontal: true
       
   315                               #useIndex: true
       
   316                               #sequenceList: #listOfLabels
       
   317                           )
       
   318                            #(#ViewSpec
       
   319                               #name: 'SpecView'
       
   320                               #component: 
       
   321                                #(#SpecCollection
       
   322                                   #collection: 
       
   323                                    #(
       
   324                                      #(#ViewSpec
       
   325                                         #name: 'TestView'
       
   326                                         #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 0 1.0)
       
   327                                         #component: 
       
   328                                          #(#SpecCollection
       
   329                                             #collection: 
       
   330                                              #(
       
   331                                                #(#TabViewSpec
       
   332                                                   #name: 'TestTabsView'
       
   333                                                   #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 0.5)
       
   334                                               )
       
   335                                             )
       
   336                                         )
       
   337                                     )
       
   338                                      #(#SubCanvasSpec
       
   339                                         #name: 'specCanvas'
       
   340                                         #layout: #(#LayoutFrame 1 0.0 0 0.0 0 1.0 -30 1.0)
       
   341                                         #specHolder: #specChannel
       
   342                                     )
       
   343                                      #(#UISubSpecification
       
   344                                         #name: 'subSpec'
       
   345                                         #layout: #(#LayoutFrame 2 0.0 -26 1 -2 1.0 -2 1)
       
   346                                         #majorKey: #ToolApplicationModel
       
   347                                         #minorKey: #windowSpecForCommit
       
   348                                     )
       
   349                                   )
       
   350                               )
       
   351                               #level: -1
       
   352                           )
       
   353                         )
       
   354                     )
       
   355                     #handles: #(#Any 0.259875 1.0)
       
   356                 )
       
   357                  #(#UISubSpecification
       
   358                     #name: 'infoBarSubSpec'
       
   359                     #layout: #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
       
   360                     #majorKey: #ToolApplicationModel
       
   361                     #minorKey: #windowSpecForInfoBar
       
   362                 )
       
   363               )
       
   364           )
       
   365       )
       
   366 ! !
       
   367 
       
   368 !TabListEditor class methodsFor:'menu specs'!
       
   369 
       
   370 menu
       
   371     "This resource specification was automatically generated
       
   372      by the MenuEditor of ST/X."
       
   373 
       
   374     "Do not manually edit this!! If it is corrupted,
       
   375      the MenuEditor may not be able to read the specification."
       
   376 
       
   377     "
       
   378      MenuEditor new openOnClass:TabListEditor andSelector:#menu
       
   379      (Menu new fromLiteralArrayEncoding:(TabListEditor menu)) startUp
       
   380     "
       
   381 
       
   382     <resource: #menu>
       
   383 
       
   384     ^
       
   385      
       
   386        #(#Menu
       
   387           
       
   388            #(
       
   389              #(#MenuItem
       
   390                 #label: 'About'
       
   391                 #activeHelpKey: #about
       
   392                 #labelImage: #(#ResourceRetriever nil #menuIcon)
       
   393                 #submenuChannel: #menuAbout
       
   394             )
       
   395              #(#MenuItem
       
   396                 #label: 'File'
       
   397                 #activeHelpKey: #file
       
   398                 #submenu: 
       
   399                  #(#Menu
       
   400                     
       
   401                      #(
       
   402                        #(#MenuItem
       
   403                           #label: 'New'
       
   404                           #value: #doNew
       
   405                           #activeHelpKey: #fileNew
       
   406                       )
       
   407                        #(#MenuItem
       
   408                           #label: '-'
       
   409                       )
       
   410                        #(#MenuItem
       
   411                           #label: 'Load...'
       
   412                           #translateLabel: true
       
   413                           #value: #doLoad
       
   414                           #activeHelpKey: #fileLoad
       
   415                       )
       
   416                        #(#MenuItem
       
   417                           #label: '-'
       
   418                       )
       
   419                        #(#MenuItem
       
   420                           #label: 'Save'
       
   421                           #value: #doSave
       
   422                           #activeHelpKey: #fileSave
       
   423                       )
       
   424                        #(#MenuItem
       
   425                           #label: 'Save As...'
       
   426                           #value: #doSaveAs
       
   427                           #activeHelpKey: #fileSave
       
   428                       )
       
   429                        #(#MenuItem
       
   430                           #label: '-'
       
   431                       )
       
   432                        #(#MenuItem
       
   433                           #label: 'Browse Class'
       
   434                           #value: #doBrowseClass
       
   435                           #activeHelpKey: #fileBrowseClass
       
   436                       )
       
   437                        #(#MenuItem
       
   438                           #label: '-'
       
   439                       )
       
   440                        #(#MenuItem
       
   441                           #label: 'Exit'
       
   442                           #value: #closeRequest
       
   443                           #activeHelpKey: #fileExit
       
   444                       )
       
   445                     ) nil
       
   446                     nil
       
   447                 )
       
   448             )
       
   449              #(#MenuItem
       
   450                 #label: 'Edit'
       
   451                 #activeHelpKey: #edit
       
   452                 #submenuChannel: #menuEdit
       
   453             )
       
   454              #(#MenuItem
       
   455                 #label: 'Add'
       
   456                 #activeHelpKey: #add
       
   457                 #submenu: 
       
   458                  #(#Menu
       
   459                     
       
   460                      #(
       
   461                        #(#MenuItem
       
   462                           #label: 'Tab Item'
       
   463                           #value: #doCreateTabItem
       
   464                           #activeHelpKey: #addTabItem
       
   465                           #labelImage: #(#ResourceRetriever nil #newTabItemIcon 'Tab Item')
       
   466                       )
       
   467                     ) nil
       
   468                     nil
       
   469                 )
       
   470             )
       
   471              #(#MenuItem
       
   472                 #label: 'Generate'
       
   473                 #activeHelpKey: #add
       
   474                 #submenu: 
       
   475                  #(#Menu
       
   476                     
       
   477                      #(
       
   478                        #(#MenuItem
       
   479                           #label: 'Aspect Method'
       
   480                           #value: #doGenerateAspectMethod
       
   481                           #activeHelpKey: #fileCreateAspectMethod
       
   482                           #enabled: #hasClassAndSelector
       
   483                       )
       
   484                     ) nil
       
   485                     nil
       
   486                 )
       
   487             )
       
   488              #(#MenuItem
       
   489                 #label: 'Test'
       
   490                 #activeHelpKey: #test
       
   491                 #submenu: 
       
   492                  #(#Menu
       
   493                     
       
   494                      #(
       
   495                        #(#MenuItem
       
   496                           #label: 'Preview'
       
   497                           #activeHelpKey: #testPreview
       
   498                           #enabled: #canShowTestMode
       
   499                           #indication: #testMode
       
   500                       )
       
   501                     ) nil
       
   502                     nil
       
   503                 )
       
   504             )
       
   505              #(#MenuItem
       
   506                 #label: 'History'
       
   507                 #activeHelpKey: #history
       
   508                 #submenuChannel: #menuHistory
       
   509             )
       
   510              #(#MenuItem
       
   511                 #label: 'Settings'
       
   512                 #submenu: 
       
   513                  #(#Menu
       
   514                     
       
   515                      #(
       
   516                        #(#MenuItem
       
   517                           #label: 'Fonts'
       
   518                           #submenuChannel: #menuFont
       
   519                       )
       
   520                     ) nil
       
   521                     nil
       
   522                 )
       
   523             )
       
   524              #(#MenuItem
       
   525                 #label: 'Help'
       
   526                 #startGroup: #right
       
   527                 #activeHelpKey: #help
       
   528                 #submenuChannel: #menuHelp
       
   529             )
       
   530           ) nil
       
   531           nil
       
   532       )
       
   533 !
       
   534 
       
   535 menuEdit
       
   536     "This resource specification was automatically generated
       
   537      by the MenuEditor of ST/X."
       
   538 
       
   539     "Do not manually edit this!! If it is corrupted,
       
   540      the MenuEditor may not be able to read the specification."
       
   541 
       
   542     "
       
   543      MenuEditor new openOnClass:TabListEditor andSelector:#menuEdit
       
   544      (Menu new fromLiteralArrayEncoding:(TabListEditor menuEdit)) startUp
       
   545     "
       
   546 
       
   547     <resource: #menu>
       
   548 
       
   549     ^
       
   550      
       
   551        #(#Menu
       
   552           
       
   553            #(
       
   554              #(#MenuItem
       
   555                 #label: 'Cut'
       
   556                 #value: #doCut
       
   557                 #activeHelpKey: #editCut
       
   558                 #enabled: #valueOfCanCut
       
   559             )
       
   560              #(#MenuItem
       
   561                 #label: 'Copy'
       
   562                 #value: #doCopy
       
   563                 #activeHelpKey: #editCopy
       
   564                 #enabled: #valueOfCanCopy
       
   565             )
       
   566              #(#MenuItem
       
   567                 #label: 'Paste'
       
   568                 #value: #doPaste
       
   569                 #activeHelpKey: #editPaste
       
   570                 #enabled: #valueOfCanPaste
       
   571             )
       
   572              #(#MenuItem
       
   573                 #label: 'Delete'
       
   574                 #value: #doDelete
       
   575                 #activeHelpKey: #editPaste
       
   576                 #enabled: #valueOfCanCut
       
   577             )
       
   578              #(#MenuItem
       
   579                 #label: '-'
       
   580             )
       
   581              #(#MenuItem
       
   582                 #label: 'Move Up'
       
   583                 #value: #doMoveTabUpOrDown:
       
   584                 #activeHelpKey: #editMoveUp
       
   585                 #enabled: #canMoveTabItemUpOrDown
       
   586                 #argument: #up
       
   587                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up')
       
   588             )
       
   589              #(#MenuItem
       
   590                 #label: 'Move Down'
       
   591                 #value: #doMoveTabUpOrDown:
       
   592                 #activeHelpKey: #editMoveDown
       
   593                 #enabled: #canMoveTabItemUpOrDown
       
   594                 #argument: #down
       
   595                 #labelImage: #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down')
       
   596             )
       
   597           ) nil
       
   598           nil
       
   599       )
       
   600 !
       
   601 
       
   602 menuToolbar
       
   603     "This resource specification was automatically generated
       
   604      by the MenuEditor of ST/X."
       
   605 
       
   606     "Do not manually edit this!! If it is corrupted,
       
   607      the MenuEditor may not be able to read the specification."
       
   608 
       
   609     "
       
   610      MenuEditor new openOnClass:TabListEditor andSelector:#menuToolbar
       
   611      (Menu new fromLiteralArrayEncoding:(TabListEditor menuToolbar)) startUp
       
   612     "
       
   613 
       
   614     <resource: #menu>
       
   615 
       
   616     ^
       
   617      
       
   618        #(#Menu
       
   619           
       
   620            #(
       
   621              #(#MenuItem
       
   622                 #label: 'New'
       
   623                 #isButton: true
       
   624                 #value: #doNew
       
   625                 #activeHelpKey: #fileNew
       
   626                 #labelImage: #(#ResourceRetriever nil #newIcon)
       
   627             )
       
   628              #(#MenuItem
       
   629                 #label: 'Load'
       
   630                 #isButton: true
       
   631                 #value: #doLoad
       
   632                 #activeHelpKey: #fileLoad
       
   633                 #labelImage: #(#ResourceRetriever nil #loadIcon)
       
   634             )
       
   635              #(#MenuItem
       
   636                 #label: 'Save'
       
   637                 #isButton: true
       
   638                 #value: #doSave
       
   639                 #activeHelpKey: #fileSave
       
   640                 #labelImage: #(#ResourceRetriever nil #saveIcon)
       
   641             )
       
   642              #(#MenuItem
       
   643                 #label: ''
       
   644             )
       
   645              #(#MenuItem
       
   646                 #label: 'Cut'
       
   647                 #isButton: true
       
   648                 #value: #doCut
       
   649                 #activeHelpKey: #editCut
       
   650                 #enabled: #valueOfCanCut
       
   651                 #labelImage: #(#ResourceRetriever nil #cutIcon)
       
   652             )
       
   653              #(#MenuItem
       
   654                 #label: 'Copy'
       
   655                 #isButton: true
       
   656                 #value: #doCopy
       
   657                 #activeHelpKey: #editCopy
       
   658                 #enabled: #valueOfCanCopy
       
   659                 #labelImage: #(#ResourceRetriever nil #copyIcon)
       
   660             )
       
   661              #(#MenuItem
       
   662                 #label: 'Paste'
       
   663                 #isButton: true
       
   664                 #value: #doPaste
       
   665                 #activeHelpKey: #editPaste
       
   666                 #enabled: #valueOfCanPaste
       
   667                 #labelImage: #(#ResourceRetriever nil #pasteIcon)
       
   668             )
       
   669              #(#MenuItem
       
   670                 #label: 'Delete'
       
   671                 #isButton: true
       
   672                 #value: #doDelete
       
   673                 #activeHelpKey: #editDelete
       
   674                 #enabled: #valueOfCanCut
       
   675                 #labelImage: #(#ResourceRetriever nil #deleteIcon)
       
   676             )
       
   677              #(#MenuItem
       
   678                 #label: ''
       
   679             )
       
   680              #(#MenuItem
       
   681                 #label: 'Add Tab Item'
       
   682                 #isButton: true
       
   683                 #value: #doCreateTabItem
       
   684                 #activeHelpKey: #addTabItem
       
   685                 #labelImage: #(#ResourceRetriever nil #newTabItemIcon)
       
   686             )
       
   687              #(#MenuItem
       
   688                 #label: ''
       
   689             )
       
   690              #(#MenuItem
       
   691                 #label: 'Move Tab Up'
       
   692                 #isButton: true
       
   693                 #value: #doMoveTabUpOrDown:
       
   694                 #activeHelpKey: #editMoveUp
       
   695                 #enabled: #canMoveTabItemUpOrDown
       
   696                 #argument: #up
       
   697                 #labelImage: #(#ResourceRetriever nil #upIcon)
       
   698             )
       
   699              #(#MenuItem
       
   700                 #label: 'Move Tab Down'
       
   701                 #isButton: true
       
   702                 #value: #doMoveTabUpOrDown:
       
   703                 #activeHelpKey: #editMoveDown
       
   704                 #enabled: #canMoveTabItemUpOrDown
       
   705                 #argument: #down
       
   706                 #labelImage: #(#ResourceRetriever nil #downIcon)
       
   707             )
       
   708              #(#MenuItem
       
   709                 #label: ''
       
   710             )
       
   711              #(#MenuItem
       
   712                 #label: 'Preview'
       
   713                 #activeHelpKey: #testPreview
       
   714                 #enabled: #canShowTestMode
       
   715                 #indication: #testMode
       
   716             )
       
   717           ) nil
       
   718           nil
       
   719       )
       
   720 ! !
       
   721 
       
   722 !TabListEditor methodsFor:'aspects'!
       
   723 
       
   724 canMoveTabItemUpOrDown
       
   725 
       
   726     |holder|
       
   727 
       
   728     (holder := builder bindingAt:#canMoveTabItemUpOrDown) isNil ifTrue:[
       
   729         builder aspectAt:#canMoveTabItemUpOrDown put:(holder := false asValue).
       
   730     ].
       
   731     ^ holder
       
   732 
       
   733 !
       
   734 
       
   735 canShowTestMode
       
   736 
       
   737     |holder|
       
   738 
       
   739     (holder := builder bindingAt:#canShowTestMode) isNil ifTrue:[
       
   740         builder aspectAt:#canShowTestMode put:(holder := false asValue).
       
   741     ].
       
   742     ^ holder
       
   743 
       
   744 !
       
   745 
       
   746 listOfLabels
       
   747     "returns a holder which keeps the list of tab labels
       
   748     "
       
   749     |list|
       
   750 
       
   751     (list := builder bindingAt:#listOfLabels) isNil ifTrue:[
       
   752         builder aspectAt:#listOfLabels put:(list :=  List new).
       
   753     ].
       
   754     ^ list
       
   755 !
       
   756 
       
   757 selectionHolder
       
   758     "holder which keeps the current selection
       
   759     "
       
   760     |holder|
       
   761 
       
   762     (holder := builder bindingAt:#selectionHolder) isNil ifTrue:[
       
   763         holder := AspectAdaptor new subject:self; forAspect:#selectedIndex.
       
   764         builder aspectAt:#selectionHolder put:holder.
       
   765     ].
       
   766     ^ holder
       
   767 !
       
   768 
       
   769 specChannel
       
   770     "holder which keeps the current tab specification
       
   771     "
       
   772     |holder|
       
   773 
       
   774     (holder := builder bindingAt:#specChannel) isNil ifTrue:[
       
   775         builder aspectAt:#specChannel put:(holder :=  ValueHolder new).
       
   776     ].
       
   777     ^ holder
       
   778 !
       
   779 
       
   780 testMode
       
   781 
       
   782     |holder|
       
   783 
       
   784     (holder := builder bindingAt:#testMode) isNil ifTrue:[
       
   785         builder aspectAt:#testMode put:(holder := false asValue).
       
   786         holder addDependent: self
       
   787     ].
       
   788     ^ holder
       
   789 
       
   790 ! !
       
   791 
       
   792 !TabListEditor methodsFor:'building'!
       
   793 
       
   794 buildFromClass:aClass andSelector:aSelector
       
   795     "build from class and selector
       
   796     "
       
   797     |cls spec list|
       
   798 
       
   799     self testMode value: false.
       
   800     self selectionHolder value:0.
       
   801 
       
   802     "if opened on a tab list"
       
   803     (aClass isNil and: [aSelector isNil and: [listOfTabs size > 0]]) 
       
   804     ifTrue: 
       
   805     [
       
   806         listOfTabs notEmpty ifTrue:[
       
   807             self selectionHolder value:1
       
   808         ].
       
   809         ^nil
       
   810     ].
       
   811 
       
   812     self listOfLabels removeAll.
       
   813     listOfTabs removeAll.
       
   814 
       
   815     testView notNil ifTrue:[
       
   816         testView lower
       
   817     ].
       
   818 
       
   819     rebuildMode := false.
       
   820 
       
   821     self canShowTestMode value: false.
       
   822 
       
   823     cls := self resolveName:aClass.
       
   824     specSelector := aSelector.
       
   825 
       
   826     cls notNil ifTrue:[
       
   827         specSelector notNil ifTrue:[
       
   828 
       
   829             (cls respondsTo:specSelector) ifTrue:[
       
   830                 spec := cls perform:specSelector.
       
   831                 list := self listOfLabels.
       
   832 
       
   833                 spec size ~~ 0 ifTrue:[
       
   834 
       
   835                     rebuildMode := true.
       
   836 
       
   837                     spec do:[:aTab|
       
   838                         list add:aTab label.
       
   839                         listOfTabs add:aTab.
       
   840                     ].
       
   841                     rebuildMode := false.          
       
   842                     self addToHistory:(cls name, ' ', specSelector) -> #loadFromMessage:                        
       
   843                 ]
       
   844             ]
       
   845         ]
       
   846     ].
       
   847 
       
   848     modified := false.
       
   849 
       
   850     listOfTabs notEmpty ifTrue:[
       
   851         self selectionHolder value:1
       
   852     ].
       
   853 
       
   854     self updateInfoLabel
       
   855 !
       
   856 
       
   857 buildFromResourceSpec: aListSpec
       
   858 
       
   859     self buildFromTabList: aListSpec
       
   860 !
       
   861 
       
   862 buildFromTabList: aTabList
       
   863     "build from a aTabList"
       
   864 
       
   865     rebuildMode := true.
       
   866 
       
   867     self selectionHolder value: nil.
       
   868     self listOfLabels removeAll.
       
   869     listOfTabs removeAll.
       
   870 
       
   871     aTabList do:[:aTabItem|
       
   872         listOfTabs add: aTabItem.
       
   873         self listOfLabels add: aTabItem label
       
   874     ].
       
   875     rebuildMode := false.          
       
   876 
       
   877     modified := false.
       
   878 
       
   879     listOfTabs notEmpty ifTrue:[
       
   880         self selectionHolder value:1
       
   881     ].
       
   882 
       
   883     self updateInfoLabel
       
   884 ! !
       
   885 
       
   886 !TabListEditor methodsFor:'change & update'!
       
   887 
       
   888 update:something with:aParameter from:someObject
       
   889     "one of my aspects has changed; update modified channel
       
   890     "
       
   891     super update:something with:aParameter from:someObject.
       
   892 
       
   893     someObject = self testMode
       
   894     ifTrue:
       
   895     [              
       
   896         someObject value
       
   897             ifTrue: [self doTest]
       
   898             ifFalse:[testView lower. self selectionHolder value:1].
       
   899 
       
   900         self updateInfoLabel
       
   901     ]
       
   902 ! !
       
   903 
       
   904 !TabListEditor methodsFor:'help'!
       
   905 
       
   906 defaultInfoLabel
       
   907 
       
   908     ^self testMode value
       
   909         ifTrue:  ['Test mode']
       
   910         ifFalse: [super defaultInfoLabel]
       
   911 ! !
       
   912 
       
   913 !TabListEditor methodsFor:'selection'!
       
   914 
       
   915 selectedIndex
       
   916     ^ selectedIndex
       
   917 !
       
   918 
       
   919 selectedIndex:anIndex
       
   920     |s oldSel|
       
   921 
       
   922     self listOfLabels notEmpty ifTrue: [self canShowTestMode value: true].
       
   923     anIndex notNil ifTrue: [self testMode value: false].
       
   924 
       
   925     oldSel := selectedIndex.
       
   926     selectedIndex := anIndex ? 0.
       
   927 
       
   928     selectedIndex == oldSel ifTrue:[^ self].
       
   929 
       
   930     oldSel == 0 ifTrue:[
       
   931         self specChannel value:(self class tabSpec)
       
   932     ] ifFalse:[
       
   933         selectedIndex == 0 ifTrue:[
       
   934             self specChannel value:nil
       
   935         ]
       
   936     ].
       
   937     self cancel.
       
   938 
       
   939     testView notNil ifTrue:[
       
   940         testView lower.
       
   941     ].
       
   942 
       
   943     self valueOfCanCut value: (anIndex ~~ 0).
       
   944     self valueOfCanCopy value: (anIndex ~~ 0).
       
   945     self valueOfCanPaste.
       
   946 
       
   947     self updateFonts
       
   948 ! !
       
   949 
       
   950 !TabListEditor methodsFor:'startup / release'!
       
   951 
       
   952 initialize
       
   953     "setup aspects used by column description specifications
       
   954     "
       
   955     |holder|
       
   956 
       
   957     super initialize.
       
   958 
       
   959     listOfTabs    := OrderedCollection new.
       
   960     selectedIndex := 0.
       
   961     rebuildMode   := false.
       
   962 
       
   963 
       
   964 !
       
   965 
       
   966 openModalOnTabList: aTabList
       
   967     "build a tab list from aTabList and open it modal"
       
   968 
       
   969     super openModalOnResourceSpec: aTabList
       
   970 
       
   971 !
       
   972 
       
   973 postBuildWith:builder
       
   974 
       
   975     super postBuildWith:builder.
       
   976 
       
   977     testView := builder componentAt:#TestView.
       
   978     (builder componentAt:#ColumnView) selectConditionBlock: [:i|self askForItemModification].
       
   979 ! !
       
   980 
       
   981 !TabListEditor methodsFor:'user actions'!
       
   982 
       
   983 accept
       
   984     "accept changes
       
   985     "
       
   986     |label|
       
   987 
       
   988     selectedIndex ~~ 0 ifTrue:[
       
   989         rebuildMode := true.
       
   990         label := listOfTabs at:selectedIndex.
       
   991 
       
   992         aspects keysAndValuesDo:[:aKey :aModel|
       
   993             label perform:(aKey , ':') asSymbol with:(aModel value).
       
   994         ].
       
   995         self listOfLabels at:selectedIndex put:(label label).
       
   996 
       
   997         rebuildMode := false.
       
   998     ].
       
   999     self cancel.
       
  1000     modified := true.
       
  1001     self valueOfEnablingCommitButtons value: false
       
  1002 !
       
  1003 
       
  1004 cancel
       
  1005     "cancel all changes
       
  1006     "
       
  1007     |tab|
       
  1008 
       
  1009     selectedIndex ~~ 0 ifTrue:[
       
  1010         tab := listOfTabs at:selectedIndex.
       
  1011 
       
  1012         rebuildMode := true.
       
  1013 
       
  1014         aspects keysAndValuesDo:[:aKey :aModel|
       
  1015             aModel value:(tab perform:aKey)    
       
  1016         ].
       
  1017 
       
  1018         rebuildMode := false.
       
  1019     ].
       
  1020     self canMoveTabItemUpOrDown value:(selectedIndex ~~ 0 and:[listOfTabs size > 1]).
       
  1021     self valueOfEnablingCommitButtons value: false
       
  1022 
       
  1023 
       
  1024 
       
  1025 !
       
  1026 
       
  1027 doCopy
       
  1028     "copy selected tab
       
  1029     "
       
  1030     selectedIndex ~~ 0 ifTrue:[
       
  1031         self clipboard:(listOfTabs at:selectedIndex) deepCopy
       
  1032     ]
       
  1033 !
       
  1034 
       
  1035 doCreateTabItem
       
  1036 
       
  1037     |tab|
       
  1038     self testMode value: false.
       
  1039     tab := TabItem label:'Tab Item ', (listOfTabs size + 1) printString.
       
  1040 
       
  1041     listOfTabs add:tab afterIndex:selectedIndex.
       
  1042     self listOfLabels add:(tab label) afterIndex:selectedIndex.
       
  1043 
       
  1044     selectedIndex == 0 ifTrue:[
       
  1045         self selectionHolder value:1
       
  1046     ] ifFalse:[    
       
  1047         self selectionHolder value:selectedIndex + 1.
       
  1048         self cancel.
       
  1049     ].
       
  1050 
       
  1051     modified := true.
       
  1052 !
       
  1053 
       
  1054 doCut
       
  1055     "cut selected tab
       
  1056     "
       
  1057     |list index|
       
  1058 
       
  1059     (index := selectedIndex) ~~ 0 ifTrue:[
       
  1060         self testMode value: false.
       
  1061         list := self listOfLabels.
       
  1062         self clipboard:(listOfTabs at:index) deepCopy.
       
  1063         self selectionHolder value:0.
       
  1064         listOfTabs removeIndex:index.
       
  1065         list removeIndex:index.
       
  1066         index > list size ifTrue:[
       
  1067             index := index - 1
       
  1068         ].
       
  1069         self selectionHolder value:index.
       
  1070         self listOfLabels isEmpty ifTrue: [self canShowTestMode value: false].
       
  1071         modified := true.
       
  1072     ].
       
  1073 
       
  1074 !
       
  1075 
       
  1076 doDelete
       
  1077     "delete selected tab
       
  1078     "
       
  1079     |list index|
       
  1080 
       
  1081     (index := selectedIndex) ~~ 0 ifTrue:[
       
  1082         self testMode value: false.
       
  1083         list := self listOfLabels.
       
  1084         self selectionHolder value:0.
       
  1085         listOfTabs removeIndex:index.
       
  1086         list removeIndex:index.
       
  1087         index > list size ifTrue:[index := index - 1].
       
  1088         self selectionHolder value:index.
       
  1089         self listOfLabels isEmpty ifTrue: [self canShowTestMode value: false].
       
  1090         modified := true.
       
  1091     ].       
       
  1092 !
       
  1093 
       
  1094 doGenerateAspectMethod
       
  1095     "generate aspect method
       
  1096     "
       
  1097     |cls code|
       
  1098 
       
  1099     (specClass notNil and:[specSelector notNil])
       
  1100     ifFalse:
       
  1101     [
       
  1102         ^self information:'No class and selector defined!!'   
       
  1103     ].
       
  1104 
       
  1105     cls := self resolveName: specClass.
       
  1106 
       
  1107     (cls canUnderstand:specSelector) ifTrue:[
       
  1108         "/ method already exists, do not overwrite the method automaticaly
       
  1109 
       
  1110         ( YesNoBox title:'method '
       
  1111                          , (Text string:('#', specSelector) emphasis:#bold)
       
  1112                          , ' already exists!!'
       
  1113                  yesText:'overwrite'
       
  1114                   noText:'cancel'
       
  1115         ) confirm ifFalse:[
       
  1116             ^ self
       
  1117         ]
       
  1118     ].
       
  1119 
       
  1120     code := '!!' , cls name , ' methodsFor:''aspects''!!\\' ,
       
  1121             specSelector , '\' ,
       
  1122             '    "Generated by the TabListEditor"\' ,
       
  1123             '\' ,
       
  1124             '    |list|\' ,
       
  1125             '\' ,
       
  1126             '    (list := builder bindingAt:#' , specSelector , ') isNil ifTrue:[\' ,
       
  1127             '        builder aspectAt:#' , specSelector, ' put:(list := self class ', specSelector, ').\' ,
       
  1128             '    ].\' ,
       
  1129             '    ^ list\' ,
       
  1130             '!! !!\\'.
       
  1131 
       
  1132     (ReadStream on:(code withCRs)) fileIn
       
  1133 
       
  1134 
       
  1135 !
       
  1136 
       
  1137 doMoveTabUpOrDown:what
       
  1138     "step up or down
       
  1139     "
       
  1140     |tab list index|
       
  1141 
       
  1142     (selectedIndex ~~ 0 and:[listOfTabs size > 1]) ifFalse:[
       
  1143         ^ self
       
  1144     ].
       
  1145 
       
  1146     list := self listOfLabels.
       
  1147     tab  := listOfTabs at:selectedIndex.
       
  1148 
       
  1149     list removeIndex:selectedIndex.
       
  1150     listOfTabs removeIndex:selectedIndex.
       
  1151 
       
  1152     what == #down ifTrue:[
       
  1153         index := selectedIndex > list size ifTrue:[1]
       
  1154                                           ifFalse:[selectedIndex + 1]
       
  1155     ] ifFalse:[
       
  1156         index := selectedIndex == 1 ifTrue:[list size + 1]
       
  1157                                    ifFalse:[selectedIndex - 1]
       
  1158     ].
       
  1159 
       
  1160     list add:(tab label) beforeIndex:index.
       
  1161     listOfTabs add:tab beforeIndex:index.
       
  1162 
       
  1163     rebuildMode := true.
       
  1164     self selectionHolder value:index.
       
  1165     rebuildMode := false.
       
  1166 
       
  1167     modified := true.
       
  1168 
       
  1169 !
       
  1170 
       
  1171 doPaste
       
  1172     "paste a tab
       
  1173     "
       
  1174     |tab|
       
  1175 
       
  1176     self testMode value: false.
       
  1177     (tab := self class clipboard deepCopy) isNil ifTrue: [^nil].
       
  1178     listOfTabs add:tab afterIndex:selectedIndex.
       
  1179     self listOfLabels add:(tab label) afterIndex:selectedIndex.
       
  1180 
       
  1181     selectedIndex == 0 ifTrue:[
       
  1182         self selectionHolder value:1
       
  1183     ] ifFalse:[    
       
  1184         self selectionHolder value:selectedIndex + 1.
       
  1185         self cancel.
       
  1186     ].
       
  1187       
       
  1188     modified  := true.
       
  1189 
       
  1190 !
       
  1191 
       
  1192 doSave
       
  1193     "generate code for class and instance
       
  1194     "
       
  1195     |cls code spec category mthd|
       
  1196 
       
  1197     (specClass notNil and:[specSelector notNil])
       
  1198     ifFalse:
       
  1199     [
       
  1200         ^self doSaveAs
       
  1201     ].
       
  1202 
       
  1203     cls := self resolveName: specClass.
       
  1204 
       
  1205     listOfTabs isEmpty ifTrue:[^self information:'No tab list defined!!'].
       
  1206 
       
  1207     spec  := WriteStream on:String new.
       
  1208     UISpecification prettyPrintSpecArray:(listOfTabs literalArrayEncoding) on:spec indent:5.
       
  1209     spec := spec contents.
       
  1210 
       
  1211     "/ if that method already exists, do not overwrite the category
       
  1212 
       
  1213     category := 'list specs'.
       
  1214 
       
  1215     (mthd := cls class compiledMethodAt:specSelector) notNil ifTrue:[
       
  1216         category := mthd category.
       
  1217     ].
       
  1218 
       
  1219     code := Character excla asString 
       
  1220             , cls name , ' class methodsFor:' , category storeString
       
  1221             , Character excla asString , '\\'
       
  1222 
       
  1223             , specSelector , '\'
       
  1224             , (self class codeGenerationComment replChar:$!! withString:'!!!!')
       
  1225             , '\\    "\'
       
  1226             , '     TabListEditor new openOnClass:' , cls name , ' andSelector:#' , specSelector , '\'
       
  1227             , '    "\'.
       
  1228 
       
  1229     code := code 
       
  1230             , '\'
       
  1231             , '    <resource: #tabList>\\'
       
  1232             , '    ^' 
       
  1233             , '     ', spec, '\'
       
  1234             , '      collect:[:aTab| TabItem new fromLiteralArrayEncoding:aTab ]'
       
  1235             , '\'
       
  1236             , Character excla asString
       
  1237             , ' '
       
  1238             , Character excla asString
       
  1239             , '\'.
       
  1240 
       
  1241     code := code withCRs.
       
  1242     (ReadStream on:code) fileIn.
       
  1243 
       
  1244     (cls canUnderstand:specSelector) ifFalse:[
       
  1245         (YesNoBox confirm:'Generate aspect method?') ifTrue:[
       
  1246             self doGenerateAspectMethod
       
  1247         ]
       
  1248     ].
       
  1249 
       
  1250     self addToHistory:(cls name, ' ', specSelector) -> #loadFromMessage:.
       
  1251     modified  := false.
       
  1252     hasSaved  := true.
       
  1253 !
       
  1254 
       
  1255 doTest
       
  1256     "run a test
       
  1257     "
       
  1258     |tabView list|
       
  1259 
       
  1260     self selectionHolder value:nil.
       
  1261 
       
  1262     listOfTabs size ~~ 0 ifTrue:[
       
  1263         list := listOfTabs collect:[:aTab||t|
       
  1264             t := aTab copy.
       
  1265             t setAttributesFromClass:specClass.
       
  1266             t
       
  1267         ]
       
  1268     ] ifFalse:[
       
  1269         list := nil
       
  1270     ].
       
  1271     tabView  := builder componentAt:#TestTabsView.
       
  1272     tabView list:list.
       
  1273     testView raise.
       
  1274 
       
  1275     self valueOfCanCut value: false.
       
  1276     self valueOfCanCopy value: false.
       
  1277     self valueOfCanPaste value: false.
       
  1278 
       
  1279 ! !
       
  1280 
       
  1281 !TabListEditor class methodsFor:'documentation'!
       
  1282 
       
  1283 version
       
  1284     ^ '$Header: /files/CVS/stx/libtool2/TabListEditor.st,v'
       
  1285 ! !