initial checkin
authorClaus Gittinger <cg@exept.de>
Wed, 22 Nov 2006 14:22:13 +0100
changeset 108 266be3c96486
parent 107 1d69365eba70
child 109 102a441aafcd
initial checkin
MCDictionaryRepository.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MCDictionaryRepository.st	Wed Nov 22 14:22:13 2006 +0100
@@ -0,0 +1,90 @@
+"{ Package: 'stx:goodies/monticello' }"
+
+MCRepository subclass:#MCDictionaryRepository
+	instanceVariableNames:'description dict'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Monticello-Repositories'
+!
+
+
+!MCDictionaryRepository methodsFor:'as yet unclassified'!
+
+= other
+	^ self == other
+!
+
+allVersionInfos
+	^ dict values collect: [:ea | ea info]
+!
+
+basicStoreVersion: aVersion
+	dict at: aVersion info put: aVersion
+!
+
+closestAncestorVersionFor: anAncestry ifNone: errorBlock
+	| info |
+	info _ anAncestry breadthFirstAncestors
+			detect: [:ea | self includesVersionWithInfo: ea]
+			ifNone: [^ errorBlock value].
+	^ self versionWithInfo: info
+!
+
+description
+
+	^ description ifNil: ['cache']
+!
+
+description: aString
+
+	description _ aString 
+!
+
+dictionary
+
+	^ dict
+!
+
+dictionary: aDictionary
+
+	dict _ aDictionary
+!
+
+includesVersionNamed: aString
+	^ dict anySatisfy: [:ea | ea info name = aString]
+!
+
+includesVersionWithInfo: aVersionInfo
+	^ dict includesKey: aVersionInfo
+!
+
+initialize
+
+	dict _ Dictionary new.
+!
+
+morphicOpen: aWorkingCopy
+	| names index infos |
+	infos _ self sortedVersionInfos.
+	infos isEmpty ifTrue: [^ self inform: 'No versions'].
+	names _ infos collect: [:ea | ea name].
+	index _ (PopUpMenu labelArray: names) startUpWithCaption: 'Open version:'.
+	index = 0 ifFalse: [(self versionWithInfo: (infos at: index)) open]
+!
+
+sortedVersionInfos
+	| sorter |
+	sorter _ MCVersionSorter new.
+	self allVersionInfos do: [:ea | sorter addVersionInfo: ea].
+	^ sorter sortedVersionInfos
+!
+
+versionWithInfo: aVersionInfo ifAbsent: errorBlock
+	^ dict at: aVersionInfo ifAbsent: errorBlock
+! !
+
+!MCDictionaryRepository class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/goodies/monticello/MCDictionaryRepository.st,v 1.1 2006-11-22 13:22:13 cg Exp $'
+! !