FilenameWidgetWithHistory.st
author Claus Gittinger <cg@exept.de>
Fri, 11 Jul 2008 17:30:38 +0200
changeset 3471 f3cde37d9d53
parent 3427 9927e4970fce
child 3472 20087c3d9dda
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3318
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     1
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     2
 COPYRIGHT (c) 2007 by eXept Software AG
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     3
              All Rights Reserved
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     4
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     5
 This software is furnished under a license and may be used
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     6
 only in accordance with the terms of that license and with the
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     8
 be provided or otherwise made available to, or used by, any
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
     9
 other person.  No title to or ownership of the software is
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    10
 hereby transferred.
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    11
"
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libwidg2' }"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
SimpleView subclass:#FilenameWidgetWithHistory
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
	instanceVariableNames:'fileNameEntryField browseButton history'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
	classVariableNames:''
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	poolDictionaries:''
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	category:'Views-Interactors'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!FilenameWidgetWithHistory class methodsFor:'documentation'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
3318
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    23
copyright
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    24
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    25
 COPYRIGHT (c) 2007 by eXept Software AG
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    26
              All Rights Reserved
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    27
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    28
 This software is furnished under a license and may be used
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    29
 only in accordance with the terms of that license and with the
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    31
 be provided or otherwise made available to, or used by, any
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    32
 other person.  No title to or ownership of the software is
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    33
 hereby transferred.
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    34
"
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    35
!
5a0aff0fd23a copyright
Claus Gittinger <cg@exept.de>
parents: 3251
diff changeset
    36
3471
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    37
documentation
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    38
"
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    39
    A Filename InputField with history-list and a browse-button, which opens a file dialog.
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    40
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    41
    [author:]
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    42
        Claus Gittinger
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    43
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    44
    [see also:]
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    45
        ComboBoxView
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    46
        FilenameEditField
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    47
        FilenameComboBoxView
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    48
"
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    49
!
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
    50
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
examples
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
                                                                        [exBegin]
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
     |top b|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
     top := StandardSystemView new.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
     top extent:(300 @ 200).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
     b := FilenameWidgetWithHistory in:top.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
     b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
     b bottomInset:(b preferredExtent y negated).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
     top open.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
                                                                        [exEnd]
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
!FilenameWidgetWithHistory methodsFor:'accessing'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
historyList
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    ^ #('a' 'b' 'c')
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
model
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
    ^ fileNameEntryField model
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
model:aFilenameHolder
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    fileNameEntryField model:aFilenameHolder.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!FilenameWidgetWithHistory methodsFor:'initialization'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
initialize
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    super initialize.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    fileNameEntryField := FilenameComboBoxView in:self.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    fileNameEntryField layout:(LayoutFrame
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
                                  leftFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
                                  rightFraction:1 offset:-22 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
                                  topFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
                                  bottomFraction:1 offset:0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    fileNameEntryField listHolder:(self historyList).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    browseButton := Button in:self.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    browseButton label:'...'.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    browseButton action:[self browseForDestinationDirectory].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    browseButton layout:(LayoutFrame
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
                                  leftFraction:1 offset:-22 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
                                  rightFraction:1 offset:-2 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
                                  topFraction:0 offset:0 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
                                  bottomFraction:1 offset:0).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
!FilenameWidgetWithHistory methodsFor:'queries'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
    preferredExtent notNil ifTrue:[
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        ^ preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
3427
9927e4970fce added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
   112
    preferredExtent := (fileNameEntryField preferredWidth + browseButton preferredWidth)
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
                       @
3427
9927e4970fce added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents: 3318
diff changeset
   114
                       (fileNameEntryField preferredHeight "max: browseButton preferredExtent y").
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    ^ preferredExtent
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
!FilenameWidgetWithHistory methodsFor:'user actions'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
browseForDestinationDirectory
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    |dir|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    Dialog aboutToOpenBoxNotificationSignal handle:[:ex |
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
        |dialog|
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        dialog := ex parameter.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
        dialog perform:#browseVisibleHolder with:true ifNotUnderstood:[].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
        ex proceed.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    ] do:[
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
        dir := Dialog 
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
                requestDirectoryName:'Destination Directory'
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
                default:(self model value ? '.' asFilename pathName).
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
    ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
    dir isEmptyOrNil ifTrue:[ ^ self ].
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    self model value:dir.
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    "Modified: / 02-10-2006 / 14:45:54 / cg"
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
! !
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
!FilenameWidgetWithHistory class methodsFor:'documentation'!
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
version
3471
f3cde37d9d53 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3427
diff changeset
   144
    ^ '$Header: /cvs/stx/stx/libwidg2/FilenameWidgetWithHistory.st,v 1.4 2008-07-11 15:30:38 cg Exp $'
3251
29b44f456526 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
! !