EditFieldWithCompletion.st
author Claus Gittinger <cg@exept.de>
Mon, 18 May 2015 16:49:06 +0200
changeset 15642 239bbe1c7328
parent 14985 8c2d0c3191db
child 15566 184cea584be5
child 16433 1d9bd92bc6a7
permissions -rw-r--r--
class: Tools::BreakpointService changed: #recompile #updateBreakPointsFor: FIX: update method info when recompompiling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	      All Rights Reserved
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libtool' }"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
EditField subclass:#EditFieldWithCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'showOptions optionsHolder optionsView optionsWindow
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
    16
		focusEventsToIgnore hadFocus completionJob'
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	classVariableNames:''
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	poolDictionaries:''
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	category:'Views-Text'
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
!EditFieldWithCompletion class methodsFor:'documentation'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
copyright
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
 COPYRIGHT (c) 2006 by eXept Software AG
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
	      All Rights Reserved
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
 This software is furnished under a license and may be used
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
 only in accordance with the terms of that license and with the
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
 be provided or otherwise made available to, or used by, any
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
 other person.  No title to or ownership of the software is
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 hereby transferred.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
documentation
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    documentation to be added.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    [author:]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
        Jan Vrany (janfrog@bruxa)
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    [instance variables:]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    [class variables:]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    [see also:]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
example_1
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    |top field label value|
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    top := StandardSystemView new.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    top
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
        extent:300 @ 300;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        label:'Live class completion field'.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    value := '' asValue.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    field := (EditFieldWithCompletion new)
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
                origin:10 @ 135 corner:280 @ 165;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
                entryCompletionBlock:[:content | Smalltalk classnameCompletion:content ];
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
                model:value.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    label := (Label new)
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
                origin:10 @ 95 corner:280 @ 115;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
                labelChannel:value.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    top
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
        add:field;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
        add:label.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    top open
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
examples
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    Opens a LiveCompletionEditField on a class name
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
                                                        [exBegin]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    LiveCompletionEditField example_1
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
                                                        [exEnd]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
!EditFieldWithCompletion methodsFor:'accepting'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
accept
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    self unselect.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    super accept.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    "Created: / 27-07-2009 / 09:38:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "Modified: / 12-02-2010 / 11:56:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!EditFieldWithCompletion methodsFor:'accessing-behavior'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
showOptions
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    ^ showOptions
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
showOptions:aBoolean
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    showOptions := aBoolean.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
!EditFieldWithCompletion methodsFor:'accessing-dimensions'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
absoluteLeft
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    | absoluteLeft view |
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    absoluteLeft := 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    view := self.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    [ view notNil ] whileTrue:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        [absoluteLeft := absoluteLeft + view left - 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
        view := view superView].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    ^absoluteLeft
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    "Created: / 08-08-2009 / 22:30:07 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
absoluteTop
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    | absoluteTop view |
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    absoluteTop := 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    view := self.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    [ view notNil ] whileTrue:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        [absoluteTop := absoluteTop + view top - 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        view := view superView].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ^absoluteTop
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "Created: / 08-08-2009 / 22:30:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!EditFieldWithCompletion methodsFor:'accessing-mvc'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
optionsHolder
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    ^ optionsHolder
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    "Created: / 09-08-2009 / 08:14:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
optionsHolder:aValueHolder
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    "set the 'options' value holder (automatically generated)"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    optionsHolder := aValueHolder.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    "Created: / 09-08-2009 / 08:14:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
!EditFieldWithCompletion methodsFor:'event handling'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
completion:best options:options 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
    |newContent oldContent|
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
    "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
    oldContent := ((self contents ? '') asString).
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
    newContent := ((best isNil or:[ best = oldContent ]) 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
                and:[ options isNilOrEmptyCollection not ]) 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
                    ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
                        options first
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
                        ""options inject:options anyOne
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
                            into:[:shortest :each | 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
                                shortest asString size > each asString size ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
                                    each
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
                                ] ifFalse:[ shortest ]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
                            ]""
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
                    ]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
                    ifFalse:[ best ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
    self contents:newContent asString.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
    self cursorCol:oldContent size + 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    oldContent size < newContent size ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
        self 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
            selectFromLine:1
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
            col:oldContent size + 1
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
            toLine:1
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
            col:newContent size
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
    ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
    "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
    options size > 1 ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
        optionsHolder value:options.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
        self showOptionsWindow
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
    ]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
    "Created: / 08-08-2009 / 22:02:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
    "Modified: / 09-08-2009 / 08:16:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    "Modified: / 13-02-2010 / 09:51:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
handleNonCommandKey: char
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
    super handleNonCommandKey: char.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    self startCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
    "Modified: / 26-07-2009 / 17:41:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
handlesKeyPress:key inView:aView
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   199
    <resource: #keyboard (#CursorDown #CursorUp)>
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   200
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
    ^aView == optionsView and:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
        [(#( #CursorDown #CursorUp ) includes: key) not].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    "Created: / 09-12-2010 / 21:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
hasKeyboardFocus:aBoolean
14985
8c2d0c3191db class: EditFieldWithCompletion
Claus Gittinger <cg@exept.de>
parents: 13871
diff changeset
   208
    #todo. "/ @jan: please explain what you are doing here...
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
    focusEventsToIgnore > 0 ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
        focusEventsToIgnore := focusEventsToIgnore - 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        xxx == 0 ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
            Transcript showCR:'--> taking focus'.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
            self takeFocus.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
            self assert: self windowGroup focusView == self.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
            hadFocus := true.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
        "            
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
        ^self].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    hadFocus == aBoolean ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
        ^self
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    aBoolean 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
        ifTrue:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
            [self selectAll]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
        ifFalse:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
            [self unselect.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
            self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    hadFocus := aBoolean.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
    ^ super hasKeyboardFocus:aBoolean
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "Created: / 08-08-2009 / 23:28:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "Modified: / 09-08-2009 / 10:14:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
    "Modified: / 09-12-2010 / 22:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
keyPress:key x:x y:y 
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   241
    "Forward certain events to optionsView if any"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
12389
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   243
    <resource: #keyboard (#CursorDown #CursorUp #Accept #Return #Escape #BackSpace #Delete)>
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    
12389
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   245
    (optionsView notNil 
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   246
     and:[#(CursorDown CursorUp) includes:key]) ifTrue:[
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   247
        optionsView keyPress:key x:x y:y.
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   248
        ^ self.
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   249
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    key = #Accept ifTrue:[self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    key = #Return ifTrue:[self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
    key = #Escape ifTrue:[self hideOptionsWindow].
12389
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   254
    (key = #BackSpace or:[key = #Delete]) ifTrue:[
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   255
        super keyPress:key x:x y:y.
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   256
        self startCompletion.
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   257
        ^ self.
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   258
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
12389
83d4d24d847c class: EditFieldWithCompletion
Stefan Vogel <sv@exept.de>
parents: 12110
diff changeset
   260
    super keyPress:key x:x y:y
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    "Created: / 08-08-2009 / 22:02:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
    "Modified: / 09-08-2009 / 14:06:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    "Modified: / 09-02-2010 / 20:47:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
keyPress:key x:x y:y view:aView
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
    self keyPress: key x:x y:y
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    "Created: / 09-12-2010 / 21:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
!EditFieldWithCompletion methodsFor:'initialization & release'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
destroy
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
    self hideOptionsWindow.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
    super destroy.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    "Created: / 08-08-2009 / 22:16:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    "Modified: / 09-08-2009 / 08:50:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
initialize
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    super initialize.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
    showOptions := true.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    optionsHolder := ValueHolder new.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    focusEventsToIgnore := 0.
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   291
    completionJob := BackgroundJob 
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   292
                        named: 'Edit Field Completion Job'
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   293
                        on:[self doCompletion].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    "Created: / 08-08-2009 / 20:24:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    "Modified: / 09-08-2009 / 08:17:09 / Jan Vrany <vranyj1@fel.cvut.cz>"
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   297
    "Modified: / 03-08-2011 / 17:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
!EditFieldWithCompletion methodsFor:'private'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
doCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
    |oldContents options best|
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    oldContents := (self contents ? '') asString.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
    options := self entryCompletionBlock 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
                valueWithOptionalArgument:oldContents
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
                and:self.
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   309
    options isNil ifTrue:[
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   310
        ^ self
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   311
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
    best := options first.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    options := options second.
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   314
    (options includes:best) ifFalse:[
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   315
        best := options 
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   316
                    detect:[:e | e asString startsWith:best asString ]
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   317
                    ifNone:[ best ]
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   318
    ].
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   319
    options isSortedCollection ifFalse:[
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   320
        options := options asSortedCollection:[:a :b | a displayString < b displayString ]
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   321
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    self sensor 
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   323
        pushUserEvent:#completion:options:
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   324
        for:self
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   325
        withArguments:(Array with:best with:options).
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
    "Created: / 26-07-2009 / 17:45:09 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
    "Modified: / 09-08-2009 / 02:51:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   329
    "Modified: / 18-11-2011 / 14:33:56 / cg"
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   330
    "Modified (format): / 20-11-2011 / 09:42:25 / cg"
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   331
    "Modified: / 20-04-2012 / 18:20:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
hideOptionsWindow
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   335
    optionsWindow notNil ifTrue:[
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   336
        optionsWindow destroy.
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   337
        optionsWindow := nil.
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   338
    ]
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
    "Created: / 08-08-2009 / 23:23:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    "Modified: / 09-08-2009 / 09:00:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   342
    "Modified: / 29-11-2011 / 11:27:03 / cg"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
showOptionsWindow
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   347
    | x y w |
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   348
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
    showOptions ifFalse:[^ self].
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   350
    optionsWindow notNil ifTrue:[ ^ self ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
    optionsView := SelectionInListModelView new
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
                    textStartLeft: textStartLeft - 2;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
                    listHolder: optionsHolder;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
                    action:[:value | self contents:value asString ];
10445
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   356
                    doubleClickAction:[:index | 
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   357
                            self contents:(optionsView at:index) asString.
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   358
                            self hideOptionsWindow.
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   359
                            self accept
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   360
                        ];
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
                    useIndex: false;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
                    " JV: Looks good to me "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
                    highlightMode: #line;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
                    font:self font;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
                    backgroundColor:self backgroundColor;
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   366
                    delegate: self;
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   367
                    yourself.
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   368
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   369
    x := self absoluteLeft + 5" - optionsView textStartLeft".
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   370
    y := self absoluteTop + self height + 1 + 5.
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   371
    w := (width * 2) + 0"((optionsView textStartLeft) * 2)".
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
    optionsWindow := StandardSystemView new
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
        bePopUpView;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
        beSlave;        
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   376
        origin:x @ y
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   377
        extent:(w min: (Screen current width - x)) @ (fontHeight * 10);
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   378
        yourself.
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
    ScrollableView   
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
        forView:optionsView 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
        hasHorizontalScrollBar:false 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
        hasVerticalScrollBar:true 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
        miniScrollerH:true 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
        miniScrollerV:false 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
        origin:0.0@0.0 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
        corner:1.0@1.0 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
        in:optionsWindow.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
    focusEventsToIgnore := 4.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
    optionsWindow open.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    "Created: / 09-08-2009 / 08:12:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    "Modified: / 09-08-2009 / 09:28:47 / Jan Vrany <vranyj1@fel.cvut.cz>"
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   395
    "Modified: / 29-11-2011 / 11:27:13 / cg"
13871
67bf2b738bb3 merged in jv's chenges
Claus Gittinger <cg@exept.de>
parents: 12389
diff changeset
   396
    "Modified: / 04-04-2012 / 13:08:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
startCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   401
    completionJob restart.
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
    "Created: / 26-07-2009 / 17:41:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   404
    "Modified (format): / 03-08-2011 / 17:50:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
!EditFieldWithCompletion class methodsFor:'documentation'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
version_CVS
14985
8c2d0c3191db class: EditFieldWithCompletion
Claus Gittinger <cg@exept.de>
parents: 13871
diff changeset
   410
    ^ '$Header: /cvs/stx/stx/libtool/EditFieldWithCompletion.st,v 1.9 2014-12-03 23:37:48 cg Exp $'
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
version_SVN
14985
8c2d0c3191db class: EditFieldWithCompletion
Claus Gittinger <cg@exept.de>
parents: 13871
diff changeset
   414
    ^ '$Id: EditFieldWithCompletion.st,v 1.9 2014-12-03 23:37:48 cg Exp $'
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
! !
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   416