VDBSettingsApplication.st
changeset 171 39774c491dbf
parent 129 974e705572ea
child 174 3f6f51330641
equal deleted inserted replaced
170:cd9615ebe6a9 171:39774c491dbf
     9 "{ Package: 'jv:vdb' }"
     9 "{ Package: 'jv:vdb' }"
    10 
    10 
    11 "{ NameSpace: Smalltalk }"
    11 "{ NameSpace: Smalltalk }"
    12 
    12 
    13 AbstractSettingsApplication subclass:#VDBSettingsApplication
    13 AbstractSettingsApplication subclass:#VDBSettingsApplication
    14 	instanceVariableNames:'infoPanel vdbPrettyPrintingEnabled vdbFrameFiltersEnabled
    14 	instanceVariableNames:'infoPanel gdbCommand'
    15 		gdbCommand vdbDebuggerLayout'
       
    16 	classVariableNames:''
    15 	classVariableNames:''
    17 	poolDictionaries:''
    16 	poolDictionaries:''
    18 	category:'VDB-UI-Others'
    17 	category:'VDB-UI-Others'
    19 !
    18 !
    20 
    19 
    92     <resource: #canvas>
    91     <resource: #canvas>
    93 
    92 
    94     ^ 
    93     ^ 
    95     #(FullSpec
    94     #(FullSpec
    96        name: windowSpec
    95        name: windowSpec
    97        uuid: '62913950-c87a-11e8-8f9c-0021ccd5e3d3'
    96        uuid: 'fed33670-91af-11e9-b25b-606720e43e2c'
    98        window: 
    97        window: 
    99       (WindowSpec
    98       (WindowSpec
   100          label: 'Java Settings'
    99          label: 'Java Settings'
   101          name: 'Java Settings'
   100          name: 'Java Settings'
   102          uuid: '10c0dbf1-3cd7-11e8-882f-0021ccd5e3d3'
   101          uuid: '10c0dbf1-3cd7-11e8-882f-0021ccd5e3d3'
   137              clientKey: infoPanel
   136              clientKey: infoPanel
   138              createNewBuilder: false
   137              createNewBuilder: false
   139            )
   138            )
   140           (VerticalPanelViewSpec
   139           (VerticalPanelViewSpec
   141              name: 'Controls'
   140              name: 'Controls'
   142              layout: (LayoutFrame 5 0 70 0 -5 1 0 1)
   141              layout: (LayoutFrame 10 0 70 0 -10 1 0 1)
   143              uuid: '10c10302-3cd7-11e8-882f-0021ccd5e3d3'
   142              uuid: '10c10302-3cd7-11e8-882f-0021ccd5e3d3'
   144              horizontalLayout: fit
   143              horizontalLayout: fit
   145              verticalLayout: top
   144              verticalLayout: top
   146              horizontalSpace: 3
   145              horizontalSpace: 3
   147              verticalSpace: 3
   146              verticalSpace: 3
   148              component: 
   147              component: 
   149             (SpecCollection
   148             (SpecCollection
   150                collection: (
   149                collection: (
   151                 (LabelSpec
   150                 (ViewSpec
   152                    label: 'GDB'
   151                    name: 'Spacer1'
   153                    name: 'GDBLabel'
   152                    uuid: 'fed33671-91af-11e9-b25b-606720e43e2c'
   154                    activeHelpKey: ExecutableLabel
   153                    extent: (Point 675 15)
   155                    uuid: '7628c0d1-c755-11e8-8f9c-0021ccd5e3d3'
       
   156                    translateLabel: true
       
   157                    adjust: left
       
   158                    extent: (Point 685 25)
       
   159                  )
       
   160                 (DividerSpec
       
   161                    name: 'Separator1'
       
   162                    uuid: 'b31b7a70-c7e9-11e8-8f9c-0021ccd5e3d3'
       
   163                    extent: (Point 685 10)
       
   164                  )
   154                  )
   165                 (ViewSpec
   155                 (ViewSpec
   166                    name: 'CommandPane'
   156                    name: 'CommandPane'
   167                    uuid: '7628c0d0-c755-11e8-8f9c-0021ccd5e3d3'
   157                    uuid: '7628c0d0-c755-11e8-8f9c-0021ccd5e3d3'
   168                    component: 
   158                    component: 
   169                   (SpecCollection
   159                   (SpecCollection
   170                      collection: (
   160                      collection: (
       
   161                       (LabelSpec
       
   162                          label: ''';gdb'' command:'
       
   163                          name: 'CommandLabel'
       
   164                          layout: (LayoutFrame 0 0 0 0 120 0 0 1)
       
   165                          uuid: 'fed33672-91af-11e9-b25b-606720e43e2c'
       
   166                          translateLabel: true
       
   167                          adjust: left
       
   168                        )
   171                       (FilenameInputFieldSpec
   169                       (FilenameInputFieldSpec
   172                          name: 'Command'
   170                          name: 'Command'
   173                          layout: (LayoutFrame 0 0 0 0 -100 1 0 1)
   171                          layout: (LayoutFrame 120 0 0 0 -100 1 0 1)
   174                          uuid: '7628c0d2-c755-11e8-8f9c-0021ccd5e3d3'
   172                          uuid: '7628c0d2-c755-11e8-8f9c-0021ccd5e3d3'
   175                          model: gdbCommand
   173                          model: gdbCommand
   176                          immediateAccept: true
   174                          immediateAccept: true
   177                          acceptOnPointerLeave: true
   175                          acceptOnPointerLeave: true
   178                          emptyFieldReplacementText: 'Autodetect'
   176                          emptyFieldReplacementText: 'Autodetect'
   186                          model: doSelectExecutable
   184                          model: doSelectExecutable
   187                        )
   185                        )
   188                       )
   186                       )
   189                     
   187                     
   190                    )
   188                    )
   191                    extent: (Point 685 25)
   189                    extent: (Point 675 25)
   192                  )
   190                  )
   193                 (ViewSpec
   191                 (ViewSpec
   194                    name: 'Spacer'
   192                    name: 'Spacer'
   195                    uuid: '7628c0d4-c755-11e8-8f9c-0021ccd5e3d3'
   193                    uuid: '7628c0d4-c755-11e8-8f9c-0021ccd5e3d3'
   196                    extent: (Point 685 15)
   194                    extent: (Point 675 15)
   197                  )
       
   198                 (CheckBoxSpec
       
   199                    label: 'Enable Pretty Printers'
       
   200                    name: 'EnablePrettyPrinters'
       
   201                    uuid: '10c10303-3cd7-11e8-882f-0021ccd5e3d3'
       
   202                    model: vdbPrettyPrintingEnabled
       
   203                    translateLabel: true
       
   204                    extent: (Point 685 22)
       
   205                  )
       
   206                 (CheckBoxSpec
       
   207                    label: 'Enable Frame Filters'
       
   208                    name: 'EnableFrameFilters'
       
   209                    uuid: '10c10304-3cd7-11e8-882f-0021ccd5e3d3'
       
   210                    model: vdbFrameFiltersEnabled
       
   211                    translateLabel: true
       
   212                    extent: (Point 685 22)
       
   213                  )
       
   214                 (ViewSpec
       
   215                    name: 'Spacer2'
       
   216                    uuid: '7628c0d4-c755-11e8-8f9c-0021ccd5e3d3'
       
   217                    extent: (Point 685 30)
       
   218                  )
       
   219                 (LabelSpec
       
   220                    label: 'User Interface'
       
   221                    name: 'UserInterfaceLabel'
       
   222                    activeHelpKey: ExecutableLabel
       
   223                    uuid: '7628c0d1-c755-11e8-8f9c-0021ccd5e3d3'
       
   224                    translateLabel: true
       
   225                    adjust: left
       
   226                    extent: (Point 685 25)
       
   227                  )
       
   228                 (DividerSpec
       
   229                    name: 'Separator2'
       
   230                    uuid: 'b31b7a71-c7e9-11e8-8f9c-0021ccd5e3d3'
       
   231                    extent: (Point 685 10)
       
   232                  )
       
   233                 (ViewSpec
       
   234                    name: 'Box1'
       
   235                    uuid: 'cba24fd0-c86e-11e8-8f9c-0021ccd5e3d3'
       
   236                    component: 
       
   237                   (SpecCollection
       
   238                      collection: (
       
   239                       (LabelSpec
       
   240                          label: 'Default Debugger Layout:'
       
   241                          name: 'Label1'
       
   242                          layout: (LayoutFrame 0 0 0 0 200 0 22 0)
       
   243                          uuid: '6ee449a0-c86f-11e8-8f9c-0021ccd5e3d3'
       
   244                          translateLabel: true
       
   245                          resizeForLabel: true
       
   246                          adjust: left
       
   247                        )
       
   248                       (VerticalPanelViewSpec
       
   249                          name: 'VerticalPanel1'
       
   250                          layout: (LayoutFrame 200 0 0 0 0 1 0 1)
       
   251                          uuid: 'cba24fd1-c86e-11e8-8f9c-0021ccd5e3d3'
       
   252                          horizontalLayout: left
       
   253                          verticalLayout: top
       
   254                          horizontalSpace: 3
       
   255                          verticalSpace: 3
       
   256                          component: 
       
   257                         (SpecCollection
       
   258                            collection: (
       
   259                             (RadioButtonSpec
       
   260                                label: 'Eclipse Layout - default'
       
   261                                name: 'RadioButton1'
       
   262                                uuid: 'cba24fd2-c86e-11e8-8f9c-0021ccd5e3d3'
       
   263                                translateLabel: true
       
   264                                model: vdbDebuggerLayout
       
   265                                isTriggerOnDown: true
       
   266                                select: layoutEclipseSpec
       
   267                                usePreferredWidth: true
       
   268                                useDefaultExtent: true
       
   269                              )
       
   270                             (RadioButtonSpec
       
   271                                label: 'IDA Pro Layout'
       
   272                                name: 'RadioButton2'
       
   273                                uuid: 'cba24fd3-c86e-11e8-8f9c-0021ccd5e3d3'
       
   274                                translateLabel: true
       
   275                                model: vdbDebuggerLayout
       
   276                                isTriggerOnDown: true
       
   277                                select: layoutIDAProSpec
       
   278                                useDefaultExtent: true
       
   279                              )
       
   280                             (RadioButtonSpec
       
   281                                label: 'Console-Only Layout'
       
   282                                name: 'RadioButton3'
       
   283                                uuid: 'cba24fd3-c86e-11e8-8f9c-0021ccd5e3d3'
       
   284                                translateLabel: true
       
   285                                model: vdbDebuggerLayout
       
   286                                isTriggerOnDown: true
       
   287                                select: layoutSingleSpec
       
   288                                useDefaultExtent: true
       
   289                              )
       
   290                             )
       
   291                           
       
   292                          )
       
   293                        )
       
   294                       )
       
   295                     
       
   296                    )
       
   297                    extent: (Point 685 70)
       
   298                  )
   195                  )
   299                 )
   196                 )
   300               
   197               
   301              )
   198              )
   302            )
   199            )
   303           )
   200           )
   304         
   201         
   305        )
   202        )
   306      )
   203      )
   307 
       
   308     "Modified: / 13-12-2018 / 11:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   309 ! !
   204 ! !
   310 
   205 
   311 !VDBSettingsApplication methodsFor:'actions'!
   206 !VDBSettingsApplication methodsFor:'actions'!
   312 
   207 
   313 doSelectExecutable
   208 doSelectExecutable
   314     | guess executable |
   209     | guess executable |
   315 
   210 
   316     guess := self gdbExecutable value asNilIfEmpty.
   211     guess := self gdbCommand value asNilIfEmpty.
   317     guess isNil ifTrue:[
   212     guess isNil ifTrue:[
   318         guess := GDBProcess gdbExecutable
   213         guess := GDBProcess gdbCommand
   319     ].
   214     ].
       
   215 
   320     [ guess notNil and:[ (guess := guess asFilename) exists not ] ] whileTrue:[ 
   216     [ guess notNil and:[ (guess := guess asFilename) exists not ] ] whileTrue:[ 
   321         | p |
   217         | p |
   322 
   218 
   323         p := guess directory.
   219         p := guess directory.
   324         (p notNil and:[ p pathName = guess pathName ]) ifTrue:[ 
   220         (p notNil and:[ p pathName = guess pathName ]) ifTrue:[ 
   325             p := nil.
   221             p := nil.
   326         ].
   222         ].
   327         guess := p.
   223         guess := p.
   328     ].
   224     ].
   329     guess isNil ifTrue:[ 
   225     guess isNil ifTrue:[ 
   330         guess := GDBProcess gdbExecutable
   226         guess := GDBProcess gdbCommand
   331     ].
   227     ].
   332     executable := Dialog requestFileName:(resources string:'Select GDB executable') default: guess ifFail:[ ^ self ].
   228     executable := Dialog requestFileName:(resources string:'Select GDB executable') default: guess ifFail:[ ^ self ].
   333     self infoPanel hide. 
   229     self infoPanel hide. 
   334     (executable includes: Character space) ifTrue:[ 
   230     (executable includes: Character space) ifTrue:[ 
   335         executable := '"' , executable , '"'.
   231         executable := '"' , executable , '"'.
   336     ].
   232     ].
   337     self gdbExecutable value: executable
   233     self gdbCommand value: executable
   338 
   234 
   339     "Created: / 03-10-2018 / 22:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   235     "Created: / 03-10-2018 / 22:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   236     "Modified: / 18-06-2019 / 10:42:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   340 ! !
   237 ! !
   341 
   238 
   342 !VDBSettingsApplication methodsFor:'aspects'!
   239 !VDBSettingsApplication methodsFor:'aspects'!
   343 
   240 
   344 aspects
   241 aspects
   345     ^ #(gdbCommand vdbPrettyPrintingEnabled vdbFrameFiltersEnabled vdbDebuggerLayout)
   242     ^ #(gdbCommand)
   346 
   243 
   347     "Created: / 10-04-2018 / 16:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   244     "Created: / 10-04-2018 / 16:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   348     "Modified: / 13-12-2018 / 11:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   245     "Modified: / 17-06-2019 / 13:38:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   349 !
   246 !
   350 
   247 
   351 gdbCommand
   248 gdbCommand
   352     <resource: #uiAspect>
   249     "return/create the 'gdbCommand' value holder (automatically generated)"
   353 
   250 
   354     gdbCommand isNil ifTrue:[
   251     gdbCommand isNil ifTrue:[
   355         gdbCommand := ValueHolder new.
   252         gdbCommand := ValueHolder new.
   356         vdbDebuggerLayout onChangeSend:#updateModifiedChannel to:self.
   253         gdbCommand onChangeSend:#doCheckSettings to:self.
   357     ].
   254         gdbCommand onChangeSend:#updateModifiedChannel to:self.
   358     ^ gdbCommand.
   255     ].
   359 
   256     ^ gdbCommand
   360     "Created: / 13-12-2018 / 11:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   257     "
       
   258     UserPreferences current gdbCommand
       
   259     "
       
   260 
       
   261     "Modified: / 18-06-2019 / 11:16:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   361 !
   262 !
   362 
   263 
   363 infoPanel
   264 infoPanel
   364     infoPanel isNil ifTrue:[
   265     infoPanel isNil ifTrue:[
   365         infoPanel := Tools::InlineMessageDialog new.
   266         infoPanel := Tools::InlineMessageDialog new.
   366     ].
   267     ].
   367     ^ infoPanel
   268     ^ infoPanel
   368 
   269 
   369     "Created: / 10-04-2018 / 16:52:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   270     "Created: / 10-04-2018 / 16:52:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   370 !
   271 ! !
   371 
   272 
   372 vdbDebuggerLayout
   273 !VDBSettingsApplication methodsFor:'checks'!
   373     <resource: #uiAspect>
   274 
   374 
   275 doCheckCommand
   375     vdbDebuggerLayout isNil ifTrue:[
   276     "Check `hg` command. Return true if `hg` command exists
   376         vdbDebuggerLayout := ValueHolder new.
   277      and of supported version, false otherwise."
   377         vdbDebuggerLayout onChangeSend:#updateModifiedChannel to:self.
   278 
   378     ].
   279     | command |
   379     ^ vdbDebuggerLayout.
   280 
   380 
   281     command := self gdbCommand value.
   381     "Modified (comment): / 05-10-2018 / 08:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   282     command isEmptyOrNil ifTrue:[         
   382 !
   283         command := GDBProcess gdbCommandDefault.
   383 
   284         command isNil ifTrue:[ 
   384 vdbFrameFiltersEnabled
   285             self infoPanel 
   385     <resource: #uiAspect>
   286                 reset;
   386 
   287                 beWarning;
   387     vdbFrameFiltersEnabled isNil ifTrue:[
   288                 message: (resources string:'Cannot find path to `gdb` command');
   388         vdbFrameFiltersEnabled := false asValue.
   289                 addButtonWithLabel: (self resources string:'Browse') action: [ self doSelectExecutable ];
   389         vdbFrameFiltersEnabled onChangeSend:#updateModifiedChannel to:self.
   290                 show. 
   390     ].
   291             ^ false                
   391     ^ vdbFrameFiltersEnabled.
   292         ].
   392 
   293     ].
   393     "Modified: / 10-04-2018 / 16:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   294     [
   394     "Modified (comment): / 05-10-2018 / 08:24:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   295         GDBProcess gdbCommandParseAndValidate:command 
   395 !
   296     ] on: GDBError do:[:ex | 
   396 
   297         self infoPanel 
   397 vdbPrettyPrintingEnabled
   298             reset;
   398     <resource: #uiAspect>
   299             beWarning;
   399 
   300             message: (resources string:ex description);
   400     vdbPrettyPrintingEnabled isNil ifTrue:[
   301             addButtonWithLabel: (self resources string:'Browse') action: [self infoPanel hide. self doSelectExecutable ];
   401         vdbPrettyPrintingEnabled := false asValue.
   302             show.            
   402         vdbPrettyPrintingEnabled onChangeSend:#updateModifiedChannel to:self.
   303         ^ false                            
   403     ].
   304     ].
   404     ^ vdbPrettyPrintingEnabled.
   305     ^ true.
   405 
   306 
   406     "Modified: / 10-04-2018 / 16:53:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   307     "Created: / 18-06-2019 / 10:47:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   407     "Modified (comment): / 05-10-2018 / 08:24:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   308 !
       
   309 
       
   310 doCheckSettings
       
   311     self doCheckCommand ifFalse:[ ^ self ].
       
   312 
       
   313     self infoPanel hide.
       
   314 
       
   315     "Created: / 18-06-2019 / 10:45:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   316 ! !
       
   317 
       
   318 !VDBSettingsApplication methodsFor:'hooks'!
       
   319 
       
   320 commonPostOpen
       
   321     self doCheckSettings
       
   322 
       
   323     "Created: / 18-06-2019 / 10:44:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   408 ! !
   324 ! !
   409 
   325 
   410 !VDBSettingsApplication methodsFor:'protocol'!
   326 !VDBSettingsApplication methodsFor:'protocol'!
   411 
   327 
   412 basicSaveSettings
   328 basicSaveSettings
   413     self gdbExecutable value = '' ifTrue:[ 
   329     self gdbCommand value = '' ifTrue:[ 
   414         self gdbExecutable setValue: nil
   330         self gdbCommand setValue: nil
   415     ].
   331     ].
   416     super basicSaveSettings.
   332     super basicSaveSettings.
   417 
   333 
   418     "Created: / 04-10-2018 / 09:46:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   334     "Created: / 04-10-2018 / 09:46:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   335     "Modified: / 17-06-2019 / 13:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
   419 ! !
   336 ! !
   420 
   337 
   421 !VDBSettingsApplication class methodsFor:'documentation'!
   338 !VDBSettingsApplication class methodsFor:'documentation'!
   422 
   339 
   423 version_HG
   340 version_HG