tools/JavaMapInspectorView.st
author vranyj1
Mon, 03 Dec 2012 22:09:19 +0000
branchdevelopment
changeset 1859 4d42d0099c74
parent 1818 2e5ed72e7dfd
child 1879 7d232ff32dde
permissions -rw-r--r--
Ignore tests in MemberVisibilityTests (package-private methods not yet supported)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1210
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     1
"{ Package: 'stx:libjava/tools' }"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     2
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     3
DictionaryInspectorView subclass:#JavaMapInspectorView
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     4
	instanceVariableNames:''
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     5
	classVariableNames:''
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     6
	poolDictionaries:''
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     7
	category:'Languages-Java-Tools-Inspectors'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     8
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
     9
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    10
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    11
!JavaMapInspectorView methodsFor:'menu actions'!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    12
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    13
doRemoveKey
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    14
    "remove selected item from keys"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    15
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    16
    |l|
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    17
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    18
    listView withWaitCursorDo:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    19
        self selectedKeys do:[:key |
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    20
            inspectedObject 
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    21
                perform: #'remove(Ljava/lang/Object;)Ljava/lang/Object;'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    22
                with: key
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    23
        ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    24
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    25
        keys := nil.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    26
        selectionIndex := selectedLine := nil.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    27
        inspectedObject changed.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    28
    ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    29
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    30
    l := listView firstLineShown.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    31
    self reinspect. "force list update"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    32
    listView scrollToLine:l.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    33
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    34
    "Created: / 04-12-2011 / 17:49:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    35
! !
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    36
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    37
!JavaMapInspectorView methodsFor:'private'!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    38
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    39
allNumericKeys
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    40
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    41
    ^false "for now"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    42
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    43
    "Created: / 04-12-2011 / 17:38:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    44
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    45
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    46
baseInspectedObjectClass
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    47
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    48
    | cls |
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    49
    cls := inspectedObject class.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    50
    [ cls name startsWith: 'java/util/' ] whileFalse:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    51
        cls := cls superclass.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    52
    ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    53
    ^cls.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    54
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    55
    "Created: / 04-12-2011 / 17:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    56
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    57
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    58
indexList
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    59
    "return a list of indexes to show in the selectionList.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    60
     Set hasMore to true, if a '...' entry should be added."
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    61
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    62
    | sortBlockForKeys allShown iterator |
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    63
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    64
    allShown := (inspectedObject perform: #'size()I') <= nShown.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    65
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    66
    (allShown and:[self allNumericKeys]) ifTrue:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    67
        sortBlockForKeys := [:a :b | a < b].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    68
    ] ifFalse:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    69
        sortBlockForKeys := [:a :b | a displayString < b displayString].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    70
    ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    71
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    72
    keys := (SortedCollection new:nShown) sortBlock:sortBlockForKeys.
1212
73653bc0b828 - few fixes in Map inspector
vranyj1
parents: 1210
diff changeset
    73
    iterator := (inspectedObject 
73653bc0b828 - few fixes in Map inspector
vranyj1
parents: 1210
diff changeset
    74
                    perform: #'keySet()Ljava/util/Set;') 
73653bc0b828 - few fixes in Map inspector
vranyj1
parents: 1210
diff changeset
    75
                    perform: #'iterator()Ljava/util/Iterator;'.
1210
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    76
    [ ( iterator perform: #'hasNext()Z' ) == 1 ] whileTrue:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    77
        keys add: ( iterator perform: #'next()Ljava/lang/Object;' ).
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    78
        keys size >= nShown ifTrue:[ 
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    79
            hasMore := true.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    80
            ^ keys
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    81
        ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    82
    ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    83
    ^ keys
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    84
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    85
    "Modified: / 10-05-2011 / 08:14:59 / cg"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    86
    "Created: / 04-12-2011 / 17:38:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    87
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    88
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    89
valueForSpecialLine:line
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    90
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    91
    line string = '-size' ifTrue:[
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    92
        ^inspectedObject perform: #'size()I'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    93
    ].
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    94
    ^super valueForSpecialLine: line
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    95
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    96
    "Created: / 04-12-2011 / 17:06:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    97
! !
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    98
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
    99
!JavaMapInspectorView methodsFor:'user interaction'!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   100
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   101
indexedValueAtIndex:idx
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   102
    |key|
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   103
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   104
    key := keys at:idx.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   105
    ^self indexedValueAtKey: key
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   106
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   107
    "Modified: / 04-12-2011 / 17:55:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   108
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   109
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   110
indexedValueAtIndex:idx put:newValue
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   111
    |key|
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   112
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   113
    key := keys at:idx.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   114
    ^inspectedObject 
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   115
        perform: #'put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   116
        with:key 
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   117
        with:newValue.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   118
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   119
    "Modified: / 04-12-2011 / 17:46:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   120
!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   121
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   122
indexedValueAtKey:key
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   123
    ^ inspectedObject 
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   124
        perform: #'get(Ljava/lang/Object;)Ljava/lang/Object;'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   125
        with: key.
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   126
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   127
    "Created: / 04-12-2011 / 17:54:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   128
! !
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   129
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   130
!JavaMapInspectorView class methodsFor:'documentation'!
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   131
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   132
version_SVN
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   133
    ^ '$Id$'
52dcaa706df5 Added custom inspector classes to ease working with java objects
vranyj1
parents:
diff changeset
   134
! !