VDBSettingsApplication.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 25 Jan 2019 13:33:51 +0000
changeset 143 df7f89efd39d
parent 129 974e705572ea
child 171 39774c491dbf
permissions -rw-r--r--
A complete rewrite of simple console ..that is not using `TerminalView`. The original (previous) implementation had various problems that were hard to fix, namely loosing some stream output in some cases. New (current) implementation uses custom console view (1VDBSimpleDebuggerConsoleView`) based on `TextCollector` rather than `TerminalView`. The resulting code is much much simpler, it does not use internal pipes nor REPL / pipe reader processes. Whole REPL runs completely in UI process.

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

AbstractSettingsApplication subclass:#VDBSettingsApplication
	instanceVariableNames:'infoPanel vdbPrettyPrintingEnabled vdbFrameFiltersEnabled
		gdbCommand vdbDebuggerLayout'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Others'
!

!VDBSettingsApplication class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBSettingsApplication class methodsFor:'initialization'!

initialize

    self installInSettings

    "Created: / 23-06-2005 / 09:27:10 / masca"
!

installInSettings
    
    Smalltalk addStartBlock:[
        AbstractLauncherApplication 
            addSettingsApplicationByClass:self name withName:'Tools/Visual VM Debugger' icon:self defaultIcon
    ]

    "Created: / 23-06-2005 / 09:27:10 / masca"
    "Modified: / 10-04-2018 / 16:56:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSettingsApplication class methodsFor:'help specs'!

helpSpec
    "This resource specification was automatically generated
     by the UIHelpTool of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIHelpTool may not be able to read the specification."

    "
     UIHelpTool openOnClass:VDBSettingsApplication
    "

    <resource: #help>

    ^ super helpSpec addPairsFrom:#(

#ExecutableLabel
'Path to GDB executable. If left empty, system GDB is used.'

)
! !

!VDBSettingsApplication class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VDBSettingsApplication andSelector:#windowSpec
     VDBSettingsApplication new openInterface:#windowSpec
     VDBSettingsApplication open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       uuid: '62913950-c87a-11e8-8f9c-0021ccd5e3d3'
       window: 
      (WindowSpec
         label: 'Java Settings'
         name: 'Java Settings'
         uuid: '10c0dbf1-3cd7-11e8-882f-0021ccd5e3d3'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 695 627)
       )
       component: 
      (SpecCollection
         collection: (
          (LabelSpec
             label: ' Visual/VM Debugger Settings'
             name: 'SettingsTitle'
             layout: (LayoutFrame 0 0 0 0 0 1 66 0)
             style: (FontDescription helvetica medium roman 18 #'iso10646-1' nil nil)
             uuid: '10c0dbf2-3cd7-11e8-882f-0021ccd5e3d3'
             backgroundColor: (Color 100.0 100.0 100.0)
             translateLabel: true
             adjust: left
           )
          (LabelSpec
             label: 'Icon'
             name: 'Icon'
             layout: (LayoutFrame -75 1 0 0 0 1 66 0)
             uuid: '10c10300-3cd7-11e8-882f-0021ccd5e3d3'
             hasCharacterOrientedLabel: false
             backgroundColor: (Color 100.0 100.0 100.0)
             translateLabel: true
             labelChannel: libjavaCupIcon
           )
          (SubCanvasSpec
             name: 'InfoPanel'
             layout: (LayoutFrame 0 0 67 0 0 1 107 0)
             uuid: '10c10301-3cd7-11e8-882f-0021ccd5e3d3'
             level: 0
             initiallyInvisible: true
             hasHorizontalScrollBar: false
             hasVerticalScrollBar: false
             clientKey: infoPanel
             createNewBuilder: false
           )
          (VerticalPanelViewSpec
             name: 'Controls'
             layout: (LayoutFrame 5 0 70 0 -5 1 0 1)
             uuid: '10c10302-3cd7-11e8-882f-0021ccd5e3d3'
             horizontalLayout: fit
             verticalLayout: top
             horizontalSpace: 3
             verticalSpace: 3
             component: 
            (SpecCollection
               collection: (
                (LabelSpec
                   label: 'GDB'
                   name: 'GDBLabel'
                   activeHelpKey: ExecutableLabel
                   uuid: '7628c0d1-c755-11e8-8f9c-0021ccd5e3d3'
                   translateLabel: true
                   adjust: left
                   extent: (Point 685 25)
                 )
                (DividerSpec
                   name: 'Separator1'
                   uuid: 'b31b7a70-c7e9-11e8-8f9c-0021ccd5e3d3'
                   extent: (Point 685 10)
                 )
                (ViewSpec
                   name: 'CommandPane'
                   uuid: '7628c0d0-c755-11e8-8f9c-0021ccd5e3d3'
                   component: 
                  (SpecCollection
                     collection: (
                      (FilenameInputFieldSpec
                         name: 'Command'
                         layout: (LayoutFrame 0 0 0 0 -100 1 0 1)
                         uuid: '7628c0d2-c755-11e8-8f9c-0021ccd5e3d3'
                         model: gdbCommand
                         immediateAccept: true
                         acceptOnPointerLeave: true
                         emptyFieldReplacementText: 'Autodetect'
                       )
                      (ActionButtonSpec
                         label: 'Browse'
                         name: 'BrowseButton'
                         layout: (LayoutFrame -100 1 0 0 -8 1 0 1)
                         uuid: '7628c0d3-c755-11e8-8f9c-0021ccd5e3d3'
                         translateLabel: true
                         model: doSelectExecutable
                       )
                      )
                    
                   )
                   extent: (Point 685 25)
                 )
                (ViewSpec
                   name: 'Spacer'
                   uuid: '7628c0d4-c755-11e8-8f9c-0021ccd5e3d3'
                   extent: (Point 685 15)
                 )
                (CheckBoxSpec
                   label: 'Enable Pretty Printers'
                   name: 'EnablePrettyPrinters'
                   uuid: '10c10303-3cd7-11e8-882f-0021ccd5e3d3'
                   model: vdbPrettyPrintingEnabled
                   translateLabel: true
                   extent: (Point 685 22)
                 )
                (CheckBoxSpec
                   label: 'Enable Frame Filters'
                   name: 'EnableFrameFilters'
                   uuid: '10c10304-3cd7-11e8-882f-0021ccd5e3d3'
                   model: vdbFrameFiltersEnabled
                   translateLabel: true
                   extent: (Point 685 22)
                 )
                (ViewSpec
                   name: 'Spacer2'
                   uuid: '7628c0d4-c755-11e8-8f9c-0021ccd5e3d3'
                   extent: (Point 685 30)
                 )
                (LabelSpec
                   label: 'User Interface'
                   name: 'UserInterfaceLabel'
                   activeHelpKey: ExecutableLabel
                   uuid: '7628c0d1-c755-11e8-8f9c-0021ccd5e3d3'
                   translateLabel: true
                   adjust: left
                   extent: (Point 685 25)
                 )
                (DividerSpec
                   name: 'Separator2'
                   uuid: 'b31b7a71-c7e9-11e8-8f9c-0021ccd5e3d3'
                   extent: (Point 685 10)
                 )
                (ViewSpec
                   name: 'Box1'
                   uuid: 'cba24fd0-c86e-11e8-8f9c-0021ccd5e3d3'
                   component: 
                  (SpecCollection
                     collection: (
                      (LabelSpec
                         label: 'Default Debugger Layout:'
                         name: 'Label1'
                         layout: (LayoutFrame 0 0 0 0 200 0 22 0)
                         uuid: '6ee449a0-c86f-11e8-8f9c-0021ccd5e3d3'
                         translateLabel: true
                         resizeForLabel: true
                         adjust: left
                       )
                      (VerticalPanelViewSpec
                         name: 'VerticalPanel1'
                         layout: (LayoutFrame 200 0 0 0 0 1 0 1)
                         uuid: 'cba24fd1-c86e-11e8-8f9c-0021ccd5e3d3'
                         horizontalLayout: left
                         verticalLayout: top
                         horizontalSpace: 3
                         verticalSpace: 3
                         component: 
                        (SpecCollection
                           collection: (
                            (RadioButtonSpec
                               label: 'Eclipse Layout - default'
                               name: 'RadioButton1'
                               uuid: 'cba24fd2-c86e-11e8-8f9c-0021ccd5e3d3'
                               translateLabel: true
                               model: vdbDebuggerLayout
                               isTriggerOnDown: true
                               select: layoutEclipseSpec
                               usePreferredWidth: true
                               useDefaultExtent: true
                             )
                            (RadioButtonSpec
                               label: 'IDA Pro Layout'
                               name: 'RadioButton2'
                               uuid: 'cba24fd3-c86e-11e8-8f9c-0021ccd5e3d3'
                               translateLabel: true
                               model: vdbDebuggerLayout
                               isTriggerOnDown: true
                               select: layoutIDAProSpec
                               useDefaultExtent: true
                             )
                            (RadioButtonSpec
                               label: 'Console-Only Layout'
                               name: 'RadioButton3'
                               uuid: 'cba24fd3-c86e-11e8-8f9c-0021ccd5e3d3'
                               translateLabel: true
                               model: vdbDebuggerLayout
                               isTriggerOnDown: true
                               select: layoutSingleSpec
                               useDefaultExtent: true
                             )
                            )
                          
                         )
                       )
                      )
                    
                   )
                   extent: (Point 685 70)
                 )
                )
              
             )
           )
          )
        
       )
     )

    "Modified: / 13-12-2018 / 11:31:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSettingsApplication methodsFor:'actions'!

doSelectExecutable
    | guess executable |

    guess := self gdbExecutable value asNilIfEmpty.
    guess isNil ifTrue:[
        guess := GDBProcess gdbExecutable
    ].
    [ guess notNil and:[ (guess := guess asFilename) exists not ] ] whileTrue:[ 
        | p |

        p := guess directory.
        (p notNil and:[ p pathName = guess pathName ]) ifTrue:[ 
            p := nil.
        ].
        guess := p.
    ].
    guess isNil ifTrue:[ 
        guess := GDBProcess gdbExecutable
    ].
    executable := Dialog requestFileName:(resources string:'Select GDB executable') default: guess ifFail:[ ^ self ].
    self infoPanel hide. 
    (executable includes: Character space) ifTrue:[ 
        executable := '"' , executable , '"'.
    ].
    self gdbExecutable value: executable

    "Created: / 03-10-2018 / 22:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSettingsApplication methodsFor:'aspects'!

aspects
    ^ #(gdbCommand vdbPrettyPrintingEnabled vdbFrameFiltersEnabled vdbDebuggerLayout)

    "Created: / 10-04-2018 / 16:53:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 13-12-2018 / 11:30:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

gdbCommand
    <resource: #uiAspect>

    gdbCommand isNil ifTrue:[
        gdbCommand := ValueHolder new.
        vdbDebuggerLayout onChangeSend:#updateModifiedChannel to:self.
    ].
    ^ gdbCommand.

    "Created: / 13-12-2018 / 11:30:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

infoPanel
    infoPanel isNil ifTrue:[
        infoPanel := Tools::InlineMessageDialog new.
    ].
    ^ infoPanel

    "Created: / 10-04-2018 / 16:52:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

vdbDebuggerLayout
    <resource: #uiAspect>

    vdbDebuggerLayout isNil ifTrue:[
        vdbDebuggerLayout := ValueHolder new.
        vdbDebuggerLayout onChangeSend:#updateModifiedChannel to:self.
    ].
    ^ vdbDebuggerLayout.

    "Modified (comment): / 05-10-2018 / 08:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

vdbFrameFiltersEnabled
    <resource: #uiAspect>

    vdbFrameFiltersEnabled isNil ifTrue:[
        vdbFrameFiltersEnabled := false asValue.
        vdbFrameFiltersEnabled onChangeSend:#updateModifiedChannel to:self.
    ].
    ^ vdbFrameFiltersEnabled.

    "Modified: / 10-04-2018 / 16:53:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 05-10-2018 / 08:24:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

vdbPrettyPrintingEnabled
    <resource: #uiAspect>

    vdbPrettyPrintingEnabled isNil ifTrue:[
        vdbPrettyPrintingEnabled := false asValue.
        vdbPrettyPrintingEnabled onChangeSend:#updateModifiedChannel to:self.
    ].
    ^ vdbPrettyPrintingEnabled.

    "Modified: / 10-04-2018 / 16:53:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 05-10-2018 / 08:24:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSettingsApplication methodsFor:'protocol'!

basicSaveSettings
    self gdbExecutable value = '' ifTrue:[ 
        self gdbExecutable setValue: nil
    ].
    super basicSaveSettings.

    "Created: / 04-10-2018 / 09:46:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBSettingsApplication class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !


VDBSettingsApplication initialize!