UX: improve memory view
authorJan Vrany <jan.vrany@labware.com>
Wed, 18 Nov 2020 07:08:41 +0000
changeset 205 fbcf9c641769
parent 204 fbf9eff7df60
child 206 c606b8fc373f
UX: improve memory view * do not show `nil` when memory dump is empty (such as when one requests zero rows * interpret empty string / invalid numbers in 'Rows' and 'Cols' as default values (so when user edits the field and erases it, it uses default number of rows / cols)
VDBMemoryApplication.st
--- a/VDBMemoryApplication.st	Tue Nov 17 20:04:06 2020 +0000
+++ b/VDBMemoryApplication.st	Wed Nov 18 07:08:41 2020 +0000
@@ -1,6 +1,7 @@
 "
 jv:vdb - Visual / VM Debugger
 Copyright (C) 2015-now Jan Vrany
+Copyright (C) 2020 LabWare
 
 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
 
@@ -24,6 +25,7 @@
 "
 jv:vdb - Visual / VM Debugger
 Copyright (C) 2015-now Jan Vrany
+Copyright (C) 2020 LabWare
 
 This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'
 
@@ -71,21 +73,19 @@
     ^ 
     #(FullSpec
        name: windowSpec
-       uuid: '069d6470-f30e-11e8-885b-0021ccd5e3d3'
+       uuid: 'b9ab7340-296c-11eb-9b5e-606720e43e2c'
        window: 
       (WindowSpec
          label: 'Memory Dump'
          name: 'Memory Dump'
          uuid: '9ba699c1-0231-11e8-b0df-606720e43e2c'
          bounds: (Rectangle 0 0 854 502)
-       )
-       component: 
+      ) component: 
       (SpecCollection
          collection: (
           (HorizontalPanelViewSpec
              name: 'HeaderBar'
-             layout: (LayoutFrame 30 0 0 0 0 1 30 0)
-             uuid: '9ba6c0d0-0231-11e8-b0df-606720e43e2c'
+             layout: (LayoutFrame 30 0 0 0 0 1 30 0) uuid: '9ba6c0d0-0231-11e8-b0df-606720e43e2c'
              horizontalLayout: rightSpaceFit
              verticalLayout: center
              horizontalSpace: 3
@@ -102,14 +102,14 @@
                    acceptOnPointerLeave: true
                    emptyFieldReplacementText: 'Address'
                    extent: (Point 249 22)
-                 )
+                )
                 (LabelSpec
                    label: 'Size:'
                    name: 'SizeLabel'
                    uuid: '9ba6c0d2-0231-11e8-b0df-606720e43e2c'
                    translateLabel: true
                    useDefaultExtent: true
-                 )
+                )
                 (PopUpListSpec
                    label: 'Size'
                    name: 'Size'
@@ -120,14 +120,14 @@
                    menu: sizeList
                    useIndex: true
                    extent: (Point 200 27)
-                 )
+                )
                 (LabelSpec
                    label: 'Format:'
                    name: 'FormatLabel'
                    uuid: '9ba6c0d4-0231-11e8-b0df-606720e43e2c'
                    translateLabel: true
                    useDefaultExtent: true
-                 )
+                )
                 (PopUpListSpec
                    label: 'Format'
                    name: 'Format'
@@ -137,18 +137,19 @@
                    model: formatHolder
                    menu: formatList
                    extent: (Point 170 27)
-                 )
+                )
                 (InputFieldSpec
                    name: 'EntryField1'
                    uuid: '9ba6c0d1-0231-11e8-b0df-606720e43e2c'
                    model: numRowsHolder
-                   type: integer
+                   type: string
                    acceptOnReturn: true
                    acceptOnTab: true
+                   converter: integerOrNilConverter
                    acceptOnPointerLeave: true
                    emptyFieldReplacementText: 'Rows'
                    extent: (Point 40 22)
-                 )
+                )
                 (InputFieldSpec
                    name: 'EntryField2'
                    uuid: '9ba6c0d1-0231-11e8-b0df-606720e43e2c'
@@ -156,41 +157,37 @@
                    type: integer
                    acceptOnReturn: true
                    acceptOnTab: true
+                   converter: integerOrNilConverter
                    acceptOnPointerLeave: true
                    emptyFieldReplacementText: 'Cols'
                    extent: (Point 40 22)
-                 )
                 )
-              
-             )
-           )
+              )
+            )
+          )
           (MenuPanelSpec
              name: 'ToolBar'
-             layout: (LayoutFrame 0 0 0 0 30 0 30 0)
-             uuid: '9ba6c0d6-0231-11e8-b0df-606720e43e2c'
+             layout: (LayoutFrame 0 0 0 0 30 0 30 0) uuid: '9ba6c0d6-0231-11e8-b0df-606720e43e2c'
              menu: toolbarMenu
              textDefault: true
-           )
+          )
           (TextEditorSpec
              name: 'MemoryView'
-             layout: (LayoutFrame 0 0 30 0 0 1 -30 1)
-             uuid: '9ba6c0d7-0231-11e8-b0df-606720e43e2c'
+             layout: (LayoutFrame 0 0 30 0 0 1 -30 1) uuid: '9ba6c0d7-0231-11e8-b0df-606720e43e2c'
              model: memoryHolder
              hasHorizontalScrollBar: true
              hasVerticalScrollBar: true
              isReadOnly: true
              hasKeyboardFocusInitially: false
              postBuildCallback: postBuildMemoryView:
-           )
+          )
           (TransparentBoxSpec
              name: 'FooterBar'
-             layout: (LayoutFrame 0 0 -30 1 0 1 0 1)
-             uuid: '9ba6c0d8-0231-11e8-b0df-606720e43e2c'
-           )
+             layout: (LayoutFrame 0 0 -30 1 0 1 0 1) uuid: '9ba6c0d8-0231-11e8-b0df-606720e43e2c'
           )
-        
-       )
-     )
+        )
+      )
+    )
 ! !
 
 !VDBMemoryApplication class methodsFor:'menu specs'!
@@ -246,9 +243,16 @@
 !VDBMemoryApplication methodsFor:'accessing'!
 
 memory: aGDBMemoryDump
-    self memoryHolder value: aGDBMemoryDump displayString.
+    | string |
+    aGDBMemoryDump isNil ifTrue: [
+        string := ''
+    ] ifFalse: [
+        string := aGDBMemoryDump displayString.
+    ].
+    self memoryHolder value: string
 
     "Created: / 26-01-2018 / 22:51:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-11-2020 / 20:23:00 / Jan Vrany <jan.vrany@labware.com>"
 ! !
 
 !VDBMemoryApplication methodsFor:'actions'!
@@ -288,6 +292,12 @@
     "Created: / 26-01-2018 / 00:49:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+integerOrNilConverter
+    ^ TypeConverter new integerOrNil
+
+    "Created: / 18-11-2020 / 07:07:13 / Jan Vrany <jan.vrany@labware.com>"
+!
+
 memoryHolder
     <resource: #uiAspect>