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