ApplicationWithFileHistory.st
author Claus Gittinger <cg@exept.de>
Tue, 14 May 2019 11:54:59 +0200
changeset 4264 783af7121fea
parent 4190 02a0592461c6
child 4266 12c13fe33766
permissions -rw-r--r--
#DOCUMENTATION by cg class: ApplicationSubView class comment/format in: #documentation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4190
02a0592461c6 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4021
diff changeset
     1
"{ Encoding: utf8 }"
02a0592461c6 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4021
diff changeset
     2
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
 COPYRIGHT (c) 2013 by Claus Gittinger
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
              All Rights Reserved
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 This software is furnished under a license and may be used
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
 hereby transferred.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ Package: 'stx:libview2' }"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    16
"{ NameSpace: Smalltalk }"
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    17
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
ApplicationModel subclass:#ApplicationWithFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	instanceVariableNames:''
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	classVariableNames:''
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
	poolDictionaries:''
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	category:'Interface-Framework'
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
ApplicationWithFileHistory class instanceVariableNames:'fileHistory'
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
 The following class instance variables are inherited by this class:
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
	ApplicationModel - ClassResources
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
	Model - 
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
	Object - 
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!ApplicationWithFileHistory class methodsFor:'documentation'!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
copyright
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
 COPYRIGHT (c) 2013 by Claus Gittinger
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
              All Rights Reserved
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
 This software is furnished under a license and may be used
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
 only in accordance with the terms of that license and with the
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
 inclusion of the above copyright notice.   This software may not
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
 be provided or otherwise made available to, or used by, any
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
 other person.  No title to or ownership of the software is
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
 hereby transferred.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
documentation
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    Support code for applications with a persistent history of 
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    previously opened files.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    [author:]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
        Claus Gittinger
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    [see also:]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
        StandardSystemView
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
        WindowGroup DeviceWorkstation
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
! !
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!ApplicationWithFileHistory class methodsFor:'file history support'!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
addToFileHistory:aFilename
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    69
    "remember a filename in this classes filehistory"
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    70
    
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    |fileHistory|
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    fileHistory := self fileHistory.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    fileHistory synchronized:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
        fileHistory addFirst:aFilename asFilename.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
        fileHistory size > self fileHistorySize ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
            fileHistory removeLast.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
        self makeFileHistoryPersistent
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    ]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    "Modified: / 09-11-2010 / 16:07:14 / cg"
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    83
    "Modified (comment): / 29-10-2017 / 10:51:11 / cg"
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
directoryForFileHistory
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    87
    "the filename where the history is made persistent"
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    88
    
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    ^ Filename homeDirectory / '.smalltalk' / (self nameWithoutPrefix)
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    "
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
     self directoryForFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    "
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    94
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
    95
    "Modified (comment): / 29-10-2017 / 10:51:29 / cg"
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
fetchFileHistoryFromPersistentStore
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
    |k index value dir fn|
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    fileHistory := OrderedSet new.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
    OperatingSystem isMSWINDOWSlike ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
        k := self registryKeyForFileHistory.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
        index := 1.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
        [
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
            value := k valueNamed:(index printString).
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
            value notNil
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
        ] whileTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
            fileHistory add:value asFilename.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
            index := index + 1
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    ] ifFalse:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
        dir := self directoryForFileHistory.
4190
02a0592461c6 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4021
diff changeset
   115
        dir isDirectory ifTrue:[
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
            fn := dir / 'history'.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
            fn exists ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
                fileHistory addAll:(fn contents collect:[:s | s asFilename])
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
            ]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
        ]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    ]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
fileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    fileHistory isNil ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
        self initializeFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
    ^ fileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   131
fileHistoryFilteredForStillExistingFilesDo:aBlock removeNonExisting:aBoolean
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   132
    |history toRemove|
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   133
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   134
    toRemove := OrderedCollection new.
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   135
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   136
    history := self fileHistory.
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   137
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   138
    history notEmptyOrNil ifTrue:[
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   139
        history synchronized:[
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   140
            history do:[:aFilename|
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   141
                aFilename exists ifTrue:[
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   142
                    aBlock value:aFilename.               
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   143
                ] ifFalse:[
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   144
                    toRemove add:aFilename.
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   145
                ]
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   146
            ].
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   147
            aBoolean ifTrue:[
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   148
                "/ remove all non-existing history entries
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   149
                toRemove do:[ : el |
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   150
                    fileHistory remove:el.
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   151
                ].
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   152
            ].
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   153
        ].
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   154
    ].
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   155
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   156
    "Created: / 29-10-2017 / 10:55:46 / cg"
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   157
!
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   158
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
fileHistorySize
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
    "defines the number of remembered files in the history"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
    ^ 20.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
initializeFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
    fileHistory := OrderedSet new.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
    self fetchFileHistoryFromPersistentStore.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
makeFileHistoryPersistent
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
    |k index dir fn|
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
    OperatingSystem isMSWINDOWSlike ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
        k := self registryKeyForFileHistory.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
        fileHistory doWithIndex:[:filePath :index |
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
            k valueNamed:(index printString) put:filePath asFilename pathName.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
        "/ remove the remaining keys
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
        index := fileHistory size + 1.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
        [
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
            k deleteValueNamed:(index printString)
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
        ] whileTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
            index := index + 1
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
    ] ifFalse:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
        (dir := self directoryForFileHistory) exists ifFalse:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
            dir recursiveMakeDirectory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
        fn := dir / 'history'.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
        fn contents:(fileHistory collect:[:fn | fn pathName]).
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
    ]
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
registryKeyForApplication
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    "HKEY_CURRENT_USER\Software\Exept\SmalltalkX\<appname>"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    |k_software k_exept k_stx k_app keyName|
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    OperatingSystem isMSWINDOWSlike ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
        keyName := self nameWithoutPrefix.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
        k_software := Win32OperatingSystem registryEntry key:'HKEY_CURRENT_USER\Software\'.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
        (k_exept := k_software subKeyNamed:'Exept') isNil ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
            k_exept := k_software createSubKeyNamed:'Exept'
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
        (k_stx := k_exept subKeyNamed:'SmalltalkX') isNil ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
            k_stx := k_exept createSubKeyNamed:'SmalltalkX'
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
        (k_app := k_stx subKeyNamed:keyName) isNil ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
            k_app := k_stx createSubKeyNamed:keyName
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
        ^ k_app
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    ^ nil
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    "
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
     self registryKeyForApplication 
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    "
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    "Created: / 11-01-2011 / 19:58:26 / cg"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
registryKeyForFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    "HKEY_CURRENT_USER\Software\Exept\SmalltalkX\<appName>\History"
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    |k_app k_history|
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
    OperatingSystem isMSWINDOWSlike ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
        k_app := self registryKeyForApplication.
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
        (k_history := k_app subKeyNamed:'History') isNil ifTrue:[
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
            k_history := k_app createSubKeyNamed:'History'
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
        ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
        ^ k_history
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    ].
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    ^ nil
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
    "
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
     self registryKeyForFileHistory
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    "
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
! !
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
!ApplicationWithFileHistory class methodsFor:'documentation'!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
version
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   248
    ^ '$Header$'
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
!
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
version_CVS
4021
503aea13fab1 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 3229
diff changeset
   252
    ^ '$Header$'
3229
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
! !
0ed3ebd3ab4b initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254