EditFieldWithCompletion.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 27 Feb 2013 12:34:59 +0000
branchjv
changeset 12431 9f0c59c742d5
parent 12401 4714b9640528
child 12435 1f1faf35be04
permissions -rw-r--r--
Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
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
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
    focusEventsToIgnore > 0 ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        focusEventsToIgnore := focusEventsToIgnore - 1.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
        "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        xxx == 0 ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
            Transcript showCR:'--> taking focus'.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
            self takeFocus.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
            self assert: self windowGroup focusView == self.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
            hadFocus := true.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
        ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
        "            
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
        ^self].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    hadFocus == aBoolean ifTrue:[
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
        ^self
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
    ].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    aBoolean 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
        ifTrue:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
            [self selectAll]
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
        ifFalse:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
            [self unselect.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
            self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
    hadFocus := aBoolean.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
    ^ super hasKeyboardFocus:aBoolean
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
    "Created: / 08-08-2009 / 23:28:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    "Modified: / 09-08-2009 / 10:14:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    "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
   237
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
keyPress:key x:x y:y 
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   240
    "Forward certain events to optionsView if any"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   242
    <resource: #keyboard (#CursorDown #CursorUp #Accept #Return #Escape #BackSpace)>
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
    (optionsView notNil and:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
        [(#( #CursorDown #CursorUp ) includes:key)]) 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
            ifTrue:[^ optionsView keyPress:key x:x y:y].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
    key = #Accept ifTrue:[self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    key = #Return ifTrue:[self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    key = #Escape ifTrue:[self hideOptionsWindow].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    key = #BackSpace ifTrue:
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
        [super 
12214
4b7eedbab2a7 - ChangeSetBrowser2: scroll to bottom after opening a changeset
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   253
"/            keyPress:#Delete x:x y:y;
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
            keyPress:#BackSpace x:x y:y.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
        ^ self startCompletion].
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
    ^ super 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
        keyPress:key
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
        x:x
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
        y:y
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
    "Created: / 08-08-2009 / 22:02:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
    "Modified: / 09-08-2009 / 14:06:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
12214
4b7eedbab2a7 - ChangeSetBrowser2: scroll to bottom after opening a changeset
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12128
diff changeset
   266
    "Modified: / 30-03-2012 / 17:34:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
keyPress:key x:x y:y view:aView
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
    self keyPress: key x:x y:y
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
    "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
   274
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
!EditFieldWithCompletion methodsFor:'initialization & release'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
destroy
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
    self hideOptionsWindow.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
    super destroy.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
    "Created: / 08-08-2009 / 22:16:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    "Modified: / 09-08-2009 / 08:50:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
initialize
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    super initialize.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    showOptions := true.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    optionsHolder := ValueHolder new.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
    focusEventsToIgnore := 0.
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   293
    completionJob := BackgroundJob 
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   294
                        named: 'Edit Field Completion Job'
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   295
                        on:[self doCompletion].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    "Created: / 08-08-2009 / 20:24:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
    "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
   299
    "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
   300
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
!EditFieldWithCompletion methodsFor:'private'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
doCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
    |oldContents options best|
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
    oldContents := (self contents ? '') asString.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
    options := self entryCompletionBlock 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
                valueWithOptionalArgument:oldContents
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
                and:self.
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   311
    options isNil ifTrue:[
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   312
        ^ self
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   313
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
    best := options first.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
    options := options second.
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   316
    (options includes:best) ifFalse:[
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   317
        best := options 
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   318
                    detect:[:e | e asString startsWith:best asString ]
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   319
                    ifNone:[ best ]
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   320
    ].
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   321
    options isSortedCollection ifFalse:[
12236
8ec3d6230b65 - Tools::LintHighlighter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12221
diff changeset
   322
        options := options asSortedCollection:[:a :b | a displayString < b displayString ]
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   323
    ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    self sensor 
10885
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   325
        pushUserEvent:#completion:options:
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   326
        for:self
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   327
        withArguments:(Array with:best with:options).
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    "Created: / 26-07-2009 / 17:45:09 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
    "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
   331
    "Modified: / 18-11-2011 / 14:33:56 / cg"
9509463c1702 changed: #doCompletion
Claus Gittinger <cg@exept.de>
parents: 10445
diff changeset
   332
    "Modified (format): / 20-11-2011 / 09:42:25 / cg"
12236
8ec3d6230b65 - Tools::LintHighlighter
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12221
diff changeset
   333
    "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
   334
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
hideOptionsWindow
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   337
    optionsWindow notNil ifTrue:[
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   338
        optionsWindow destroy.
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   339
        optionsWindow := nil.
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   340
    ]
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
    "Created: / 08-08-2009 / 23:23:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
    "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
   344
    "Modified: / 29-11-2011 / 11:27:03 / cg"
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
showOptionsWindow
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
12221
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   349
    | x y w |
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   350
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
    showOptions ifFalse:[^ self].
10913
f91715a29502 changed:
Claus Gittinger <cg@exept.de>
parents: 10885
diff changeset
   352
    optionsWindow notNil ifTrue:[ ^ self ].
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
    optionsView := SelectionInListModelView new
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
                    textStartLeft: textStartLeft - 2;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
                    listHolder: optionsHolder;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
                    action:[:value | self contents:value asString ];
10445
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   358
                    doubleClickAction:[:index | 
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   359
                            self contents:(optionsView at:index) asString.
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   360
                            self hideOptionsWindow.
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   361
                            self accept
70c71811bd97 comment/format in:
Stefan Vogel <sv@exept.de>
parents: 10443
diff changeset
   362
                        ];
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
                    useIndex: false;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
                    " JV: Looks good to me "
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
                    highlightMode: #line;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
                    font:self font;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
                    backgroundColor:self backgroundColor;
12221
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   368
                    delegate: self;
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   369
                    yourself.
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   370
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   371
    x := self absoluteLeft + 5" - optionsView textStartLeft".
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   372
    y := self absoluteTop + self height + 1 + 5.
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   373
    w := (width * 2) + 0"((optionsView textStartLeft) * 2)".
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
    optionsWindow := StandardSystemView new
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
        bePopUpView;
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
        beSlave;        
12221
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   378
        origin:x @ y
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   379
        extent:(w min: (Screen current width - x)) @ (fontHeight * 10);
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   380
        yourself.
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
    ScrollableView   
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
        forView:optionsView 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
        hasHorizontalScrollBar:false 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
        hasVerticalScrollBar:true 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
        miniScrollerH:true 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
        miniScrollerV:false 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
        origin:0.0@0.0 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
        corner:1.0@1.0 
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
        in:optionsWindow.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    focusEventsToIgnore := 4.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    optionsWindow open.
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    "Created: / 09-08-2009 / 08:12:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    "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
   397
    "Modified: / 29-11-2011 / 11:27:13 / cg"
12221
413e98858ddc - EditFieldWithCompletion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12214
diff changeset
   398
    "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
   399
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
startCompletion
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
10443
eed0953d70a6 Use BackgroundJob to do the search in background
vrany
parents: 10025
diff changeset
   403
    completionJob restart.
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    "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
   406
    "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
   407
! !
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
!EditFieldWithCompletion class methodsFor:'documentation'!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
version_CVS
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   412
    ^ '$Header: /cvs/stx/stx/libtool/EditFieldWithCompletion.st,v 1.6 2013-01-17 10:47:17 cg Exp $'
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
!
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
12431
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12401
diff changeset
   415
version_HG
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12401
diff changeset
   416
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12401
diff changeset
   417
    ^ '$Changeset: <not expanded> $'
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12401
diff changeset
   418
!
9f0c59c742d5 Added LintRuleSettingsApplication and LintRuleEditDialog to define user-defined rule sets.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12401
diff changeset
   419
10025
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
version_SVN
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
    ^ '§Id: EditFieldWithCompletion.st 7662 2010-12-09 21:05:19Z vranyj1 §'
cdf041762f27 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
! !
12110
7231e996222a changed: #keyPress:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 10913
diff changeset
   423