<?xml version="1.0"?>

<st-source>
<!-- 
Name: Store-Bridge
BundleName: Store-Bridge
BundleStructure: a Store.BundleForParcel
Comment: The Store Bridge can help with the the task of migrating applications between ENVY/Developer and Store. It provides two principle functions. First, it assists by converting the organization of a project, preserving the hierarchical composition of its components; and second, it provides precise control over how the version history of a project is migrated. Thus, when migrating from ENVY to Store, a configuration map is converted into a bundle, while applications and subapplications are converted into either bundles or packages, depending upon the nesting of subapplications.

Further information on the Store Bridge can be found in the "Source Code Management Guide" (located in the /doc subdirectory of the VisualWorks installation).
DevelopmentPrerequisites: #(#(#any 'StoreBase' ''))
Parcel: #('Store-Bridge')
ParcelName: Store-Bridge
PrerequisiteParcels: #(#('StoreBase' ''))
Version: 7
Date: 10:01:15 am May 20, 2002
 -->
<time-stamp>From VisualWorks®, Pre-Release 7 of May 13, 2002 on May 20, 2002 at 10:01:15 am</time-stamp>


<do-it>(Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned.  Choose terminate or close.']</do-it>

<name-space>
<name>ENVY</name>
<environment>Smalltalk</environment>
<private>false</private>
<imports>
			Applications.*
			Smalltalk.*
			</imports>
<category>ENVY/Manager</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</name-space>

<name-space>
<name>Applications</name>
<environment>Smalltalk</environment>
<private>false</private>
<imports>
			ENVY.*
			Smalltalk.*
			</imports>
<category>ENVY/Manager</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</name-space>

<class>
<name>SubApplication</name>
<environment>ENVY</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars>timeStamp timeStamps defined extended undefined subApplications parent rootApplication configurationExpression isScratchEdition library privileges </class-inst-vars>
<imports></imports>
<category>ENVY/Manager</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</class>

<class>
<name>Application</name>
<environment>ENVY</environment>
<super>ENVY.SubApplication</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars>prerequisites dependentApplications </class-inst-vars>
<imports></imports>
<category>ENVY/Manager</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</class>

<class>
<name>ConvertedConfigurationMapVersionPolicy</name>
<environment>Store</environment>
<super>Store.BranchingVersionPolicy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Store-Bridge</category>
<attributes>
<package>StoreBridge</package>
</attributes>
</class>

<class>
<name>ConfigurationMapConvertor</name>
<environment>Store</environment>
<super>UI.ApplicationModel</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>candidateParcels removeEmptyPackages removePackagerProperties useStoredVersionNames addENVYCompat </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>StoreBridge</category>
<attributes>
<package>StoreBridge</package>
</attributes>
</class>

<class>
<name>SubApplication</name>
<environment>Smalltalk</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars>timeStamp timeStamps defined extended undefined subApplications parent rootApplication configurationExpression isScratchEdition library privileges </class-inst-vars>
<imports></imports>
<category>Kernel-EmApplicationSupport</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</class>

<class>
<name>Application</name>
<environment>Smalltalk</environment>
<super>SubApplication</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars>prerequisites dependentApplications </class-inst-vars>
<imports></imports>
<category>Kernel-EmApplicationSupport</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</class>

<shared-variable>
<name>KnownTypes</name>
<environment>Store.ConfigurationMapConvertor</environment>
<private>false</private>
<constant>false</constant>
<category>local globals</category>
<initializer>
		(Core.Dictionary new)
			at: 'B' put: #bundleNamed:;
			at: 'P' put: #packageNamed:;
			yourself</initializer>
<attributes>
<package>StoreBridge</package>
</attributes>
</shared-variable>

<shared-variable>
<name>DiscardablePropertyKeys</name>
<environment>Store.ConfigurationMapConvertor</environment>
<private>false</private>
<constant>false</constant>
<category>local globals</category>
<initializer>
		(Core.List new)
			add: #tobcdata;
			add: #tocData;
			add: #versionInformation;
			add: #theBundleName;
			yourself</initializer>
<attributes>
<package>StoreBridge</package>
</attributes>
</shared-variable>

<shared-variable>
<name>LoadedApplications</name>
<environment>Application</environment>
<private>false</private>
<constant>false</constant>
<category>As yet unclassified</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</shared-variable>

<shared-variable>
<name>RootOfHierarchy</name>
<environment>Application</environment>
<private>false</private>
<constant>false</constant>
<category>As yet unclassified</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</shared-variable>

<shared-variable>
<name>LoadedSubApplications</name>
<environment>SubApplication</environment>
<private>false</private>
<constant>false</constant>
<category>As yet unclassified</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</shared-variable>

<shared-variable>
<name>Default</name>
<environment>SubApplication</environment>
<private>false</private>
<constant>false</constant>
<category>As yet unclassified</category>
<attributes>
<package>ENVY Compatibility</package>
</attributes>
</shared-variable>

<methods>
<class-id>ENVY.SubApplication class</class-id> <category>EM-API</category>

<body package="ENVY Compatibility">classes
	^#()</body>

<body package="ENVY Compatibility">defined
	^#()</body>

<body package="ENVY Compatibility">definedClasses
	^#()</body>

<body package="ENVY Compatibility">failedRemove</body>

<body package="ENVY Compatibility">loaded</body>

<body package="ENVY Compatibility">removing</body>
</methods>

<methods>
<class-id>ENVY.SubApplication class</class-id> <category>EM-Internal</category>

<body package="ENVY Compatibility">addToSystemMenu</body>

<body package="ENVY Compatibility">exiting</body>

<body package="ENVY Compatibility">restart</body>

<body package="ENVY Compatibility">saving</body>

<body package="ENVY Compatibility">shutDown</body>

<body package="ENVY Compatibility">startUp</body>
</methods>

<methods>
<class-id>Store.ConvertedConfigurationMapVersionPolicy</class-id> <category>accessing</category>

<body package="StoreBridge">initialVersionForPundle: aPundle
	| version |
	^(version := aPundle propertyAt: #envyVersion) isNil
			ifTrue: [super initialVersionForPundle: aPundle]
			ifFalse: [version]</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>aspects</category>

<body package="StoreBridge">addENVYCompat
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^addENVYCompat isNil
		ifTrue:
			[addENVYCompat := false asValue]
		ifFalse:
			[addENVYCompat]</body>

<body package="StoreBridge">candidateParcels
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^candidateParcels isNil
		ifTrue:
			[candidateParcels := MultiSelectionInList new]
		ifFalse:
			[candidateParcels]</body>

<body package="StoreBridge">removeEmptyPackages
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^removeEmptyPackages isNil
		ifTrue:
			[removeEmptyPackages := false asValue]
		ifFalse:
			[removeEmptyPackages]</body>

<body package="StoreBridge">removePackagerProperties
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^removePackagerProperties isNil
		ifTrue:
			[removePackagerProperties := false asValue]
		ifFalse:
			[removePackagerProperties]</body>

<body package="StoreBridge">useStoredVersionNames
	"This method was generated by UIDefiner.  Any edits made here
	may be lost whenever methods are automatically defined.  The
	initialization provided below may have been preempted by an
	initialize method."

	^useStoredVersionNames isNil
		ifTrue:
			[useStoredVersionNames := false asValue]
		ifFalse:
			[useStoredVersionNames]</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>private</category>

<body package="StoreBridge">createShapeFor: parcel
	"Return the newly created Bundle."
	| tc |
	tc := Registry tableOfBundleContentsFrom: (parcel propertyAt: #tobcData) readStream.
	tc do: [:tci | Registry executeTableOfBundleContents: tci].
	tc := Registry tableOfContentsFrom: (parcel propertyAt: #tocData) readStream.
	Registry executeTableOfContents: tc.
	^Registry bundleNamed: (parcel propertyAt: #theBundleName)</body>

<body package="StoreBridge">removeInitalPackage: parcel
	| initialPackage |
	initialPackage := Registry packageNamed: parcel name.
	initialPackage isEmpty ifFalse: 
		[^Dialog warn: ('Unable to remove &lt;1s&gt;!\nIt is not empty' expandMacrosWith: parcel name)].</body>

<body package="StoreBridge">setupActionBlocksFor: aPackage

	| classDesc theClass itsSelectors |
	classDesc := aPackage classesDefinedInPackage 
						detect: 
							[:classDescription | 
							(classDescription actual inheritsFrom: ENVY.SubApplication) 
							or: [classDescription actual inheritsFrom: Smalltalk.SubApplication]]
						ifNone: [nil].
	classDesc isNil ifTrue: 
		[^Dialog warn: ('No application class in &lt;1s&gt;?' expandMacrosWith: aPackage name)].

	theClass := classDesc actual.
	itsSelectors := theClass class selectors.
	(itsSelectors includes: #loaded) ifTrue:
		[aPackage postLoadAction: ('[:pkg | &lt;1p&gt; loaded]' expandMacrosWith: theClass)].
	(itsSelectors includes: #removing) ifTrue:
		[aPackage preUnloadBlock: ('[:pkg | &lt;1p&gt; removing]' expandMacrosWith: theClass)].</body>

<body package="StoreBridge">setupAllActionBlocksFor: aBundle
	| allPackages |
	allPackages := aBundle allContainedItems select: [:each | each isPackage].
	allPackages do: [:package | self setupActionBlocksFor: package]</body>

<body package="StoreBridge">storeVersionNamesFor: parcel
	| versionInfoString versionInfo |
	(versionInfoString := parcel propertyAt: #versionInformation) isNil ifTrue: 
		[^Dialog warn: 'No version numbers captured!'].
	versionInfo := versionInfoString tokensBasedOn: Character cr.
	versionInfo removeLast.  "Always an empty String, so discard it."
	1 to: versionInfo size by: 3 do: 
		[:index |
		| pundleName pundleVersion pundleType requestSelector pundle |
		pundleName := versionInfo at: index.
		pundleType := versionInfo at: index + 1.
		pundleVersion := versionInfo at: index + 2.
		requestSelector := KnownTypes
								at: pundleType 
								ifAbsent: [^self error: 'Version Information string appears to be corrupted'].
		pundle := Store.Registry perform: requestSelector with: pundleName.
		pundle isNil 
			ifTrue: 
				[Dialog warn: ('Unable to find pundle named &lt;1s&gt;' expandMacrosWith: pundleName)]
			ifFalse:
				[pundle propertyAt: #envyVersion put: pundleVersion]]</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>menu actions</category>

<body package="StoreBridge">updateList
	self candidateParcels list: self class candidateParcels.</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>actions</category>

<body package="StoreBridge">cancel
	self closeRequest</body>

<body package="StoreBridge">convert
	self candidateParcels selections do: 
		[:parcel | | newBundle |
		newBundle := Cursor execute showWhile: [self createShapeFor: parcel].
		self useStoredVersionNames value ifTrue:
			[self storeVersionNamesFor: parcel].
		self setupAllActionBlocksFor: newBundle.
		self removeEmptyPackages value ifTrue:
			[self removeInitalPackage: parcel].
		self addENVYCompat value ifTrue:
			[self addENVYCompatPrereqFor: newBundle]].</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>As yet unclassified</category>

<body package="StoreBridge">addENVYCompatPrereqFor: aBundle
	"Add the ENVY Compatibility package as a development pre-requisite"

	aBundle developmentPrerequisites: #(#(#package 'ENVY Compatibility' '')).</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor</class-id> <category>initialize-release</category>

<body package="StoreBridge">initialize
	super initialize.
	self candidateParcels list: self class candidateParcels.
	self removeEmptyPackages value: true.
	self removePackagerProperties value: true.
	self useStoredVersionNames value: true.
	self addENVYCompat value: true.</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor class</class-id> <category>accessing</category>

<body package="StoreBridge">messageCatalogID
	"This method was generated by UIDefiner."

	^#storeBridge</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor class</class-id> <category>utilities</category>

<body package="StoreBridge">candidateParcels
	"Return the Parcels that have tobcData."

	^Parcel parcels select: [:p | (p propertyAt: #tobcData) notNil]</body>
</methods>

<methods>
<class-id>SubApplication class</class-id> <category>EM-API</category>

<body package="ENVY Compatibility">classes
	^ENVY.SubApplication classes</body>

<body package="ENVY Compatibility">defined
	^ENVY.SubApplication defined</body>

<body package="ENVY Compatibility">definedClasses
	^ENVY.SubApplication definedClasses</body>

<body package="ENVY Compatibility">failedRemove
	^ENVY.SubApplication failedRemove</body>

<body package="ENVY Compatibility">loaded
	^ENVY.SubApplication loaded</body>

<body package="ENVY Compatibility">removing
	^ENVY.SubApplication removing</body>
</methods>

<methods>
<class-id>SubApplication class</class-id> <category>EM-Internal</category>

<body package="ENVY Compatibility">addToSystemMenu
	^ENVY.SubApplication addToSystemMenu</body>

<body package="ENVY Compatibility">exiting
	^ENVY.SubApplication exiting</body>

<body package="ENVY Compatibility">restart
	^ENVY.SubApplication restart</body>

<body package="ENVY Compatibility">saving
	^ENVY.SubApplication saving</body>

<body package="ENVY Compatibility">shutDown
	^ENVY.SubApplication shutDown</body>

<body package="ENVY Compatibility">startUp
	^ENVY.SubApplication startUp</body>
</methods>

<methods>
<class-id>Store.PublishPundleDialog class</class-id> <category>interface opening</category>

<body package="StoreBridge">publishFormerConfigMap: anImageBundle 

	|  coll existingVersionPolicy |
	( self validateForPublishing: ( anImageBundle containedItems addFirst: anImageBundle; yourself ) )
		ifFalse: [ ^self ].
	existingVersionPolicy := Policies versionPolicy.
	"Ensure that version used for the userdata is what was published in ENVY."
	coll := 
		[Policies versionPolicy: ConvertedConfigurationMapVersionPolicy new.
		self userDataFrom: anImageBundle] 
			ensure: [Policies versionPolicy: existingVersionPolicy].

	self new openWith: coll.</body>
</methods>

<methods>
<class-id>Kernel.CodeComponent</class-id> <category>testing</category>

<body package="StoreBridge">isFormerConfigurationMap
	^(self propertyAt: #tobcData) notNil</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor class</class-id> <category>interface specs</category>

<body package="StoreBridge">windowSpec
	"UIPainter new openOnClass: self andSelector: #windowSpec"

	&lt;resource: #canvas&gt;
	^#(#{UI.FullSpec} 
		#window: 
		#(#{UI.WindowSpec} 
			#label: 'Candidate Parcels' 
			#min: #(#{Core.Point} 640 358 ) 
			#max: #(#{Core.Point} 640 358 ) 
			#bounds: #(#{Graphics.Rectangle} 192 205 832 563 ) 
			#flags: 4 
			#menu: #windowMenu ) 
		#component: 
		#(#{UI.SpecCollection} 
			#collection: #(
				#(#{UI.SequenceViewSpec} 
					#layout: #(#{Graphics.LayoutFrame} 10 0 25 0 -11 1 147 0 ) 
					#name: #candidateParcels 
					#model: #candidateParcels 
					#multipleSelections: true 
					#useModifierKeys: true 
					#selectionType: #highlight ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.LayoutFrame} 3 0 3 0 -3 1 157 0 ) 
					#label: 'Candidate Parcels:' ) 
				#(#{UI.CheckBoxSpec} 
					#layout: #(#{Core.Point} 12 192 ) 
					#name: #removePackagerProperties 
					#model: #removePackagerProperties 
					#label: 'Remove Packager Properties' ) 
				#(#{UI.CheckBoxSpec} 
					#layout: #(#{Core.Point} 12 216 ) 
					#name: #removeEmptyPackages 
					#model: #removeEmptyPackages 
					#label: 'Remove Empty Packages' ) 
				#(#{UI.GroupBoxSpec} 
					#layout: #(#{Graphics.LayoutFrame} 3 0 166 0 -3 1 272 0 ) 
					#label: 'Conversion Actions:' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.LayoutFrame} -102 1 -50 1 -5 1 -17 1 ) 
					#name: #cancel 
					#model: #cancel 
					#label: 'Cancel' 
					#defaultable: true ) 
				#(#{UI.CheckBoxSpec} 
					#layout: #(#{Core.Point} 12 240 ) 
					#name: #useStoredVersionNames 
					#model: #useStoredVersionNames 
					#label: 'Use Stored Version Names' ) 
				#(#{UI.ActionButtonSpec} 
					#layout: #(#{Graphics.Rectangle} 415 286 512 319 ) 
					#name: #convert 
					#model: #convert 
					#label: 'Convert' 
					#isDefault: true 
					#defaultable: true ) 
				#(#{UI.CheckBoxSpec} 
					#layout: #(#{Core.Point} 191 193 ) 
					#name: #addENVYCompat 
					#model: #addENVYCompat 
					#label: 'Add ENVY Compatibility development prerequisite' ) ) ) )</body>
</methods>

<methods>
<class-id>Store.ConfigurationMapConvertor class</class-id> <category>resources</category>

<body package="StoreBridge">windowMenu
	"MenuEditor new openOnClass: self andSelector: #windowMenu"

	&lt;resource: #menu&gt;
	^#(#{UI.Menu} #(
			#(#{UI.MenuItem} 
				#rawLabel: '&amp;File' 
				#nameKey: #file 
				#submenu: #(#{UI.Menu} #(
						#(#{UI.MenuItem} 
							#rawLabel: 'Update List' 
							#nameKey: #updateList 
							#value: #updateList ) 
						#(#{UI.MenuItem} 
							#rawLabel: '&amp;Exit' ) ) #(1 1 ) nil ) ) ) #(1 ) nil ) decodeAsLiteralArray</body>
</methods>

<methods>
<class-id>Store.PundleHierarchyBrowserHelper</class-id> <category>store bridge</category>

<body package="StoreBridge">publishFormerConfigurationMap
	&lt;menuItem: 'Publish Former Configuration Map...'
		nameKey: nil
		menu: #(#listMenu)
		position: 10.03&gt;

	self dbManager doIfOnlineImage: 
		[Cursor wait showWhile: 
			[| theBundle |
			theBundle := self selection.
			theBundle isNil ifTrue: [^self].
			Cursor execute showWhile: [Undeclared purgeUnusedBindings].
			PublishPundleDialog publishFormerConfigMap: theBundle]]</body>
</methods>

<methods>
<class-id>Tools.VisualLauncher</class-id> <category>store menus</category>

<body package="StoreBridge">convertConfigurationMap
	&lt;menuItem: 'Convert Configuration Map...'
		icon: nil
		nameKey: nil
		menu: #(#menuBar #store)
		position: 70.01&gt;

	Store.ConfigurationMapConvertor open</body>
</methods>

<do-it>"Imported Classes:"</do-it>

<do-it>self error: 'Attempting to file-in parcel imports.  Choose terminate or close'</do-it>

<class>
<name>Object</name>
<environment>Core</environment>
<super></super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Kernel-Objects</category>
<attributes>
<package>Kernel-Objects</package>
</attributes>
</class>

<class>
<name>PundleHierarchyBrowserHelper</name>
<environment>Store</environment>
<super>Store.PackageBrowserHelper</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Store-UI-Browser</category>
<attributes>
<package>Store-UI-Browser</package>
</attributes>
</class>

<class>
<name>BranchingVersionPolicy</name>
<environment>Store</environment>
<super>Store.BasicVersionPolicy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Store-User Management</category>
<attributes>
<package>Store-User Management</package>
</attributes>
</class>

<class>
<name>ApplicationModel</name>
<environment>UI</environment>
<super>UI.Model</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>builder uiSession eventHandlers </inst-vars>
<class-inst-vars>savedWindowInformation </class-inst-vars>
<imports></imports>
<category>UIBuilder-Framework</category>
<attributes>
<package>UIBuilder-Framework</package>
</attributes>
</class>

<class>
<name>VisualLauncher</name>
<environment>Tools</environment>
<super>UI.ApplicationModel</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>menuBar toolBar oldHeight textCollector </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Tools-Misc</category>
<attributes>
<package>Tools-Misc</package>
</attributes>
</class>

<class>
<name>CodeComponent</name>
<environment>Kernel</environment>
<super>Core.Object</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>name properties </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>System-Code Components</category>
<attributes>
<package>System-Code Components</package>
</attributes>
</class>

</st-source>
