'From Squeak3.1alpha of 5 February 2001 [latest update: #3650] on 19 February 2001 at 8:44:17 am'! "Change Set: cachedLoads Date: 19 February 2001 Author: Bob Arning Chanes in project loading: - when projects are loaded, they are saved in Squeaklets directory (as Publish already did) - when loading a project, first check Squeaklets directory and load from there if found"! !CodeLoader methodsFor: 'installing' stamp: 'RAA 2/19/2001 08:23'! installProject "Assume that we're loading a single file and it's a project" | aStream | aStream _ sourceFiles first contentStream. aStream ifNil:[^self error:'Project was not loaded']. ProjectLoading openName: nil "<--do we want to cache this locally? Need a name if so" stream: aStream fromDirectory: nil withProjectView: nil. ! ! !FileList2 methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 07:38'! limitedSuperSwikiDirectoryList | dir nameToShow dirList | dirList _ OrderedCollection new. ServerDirectory serverNames do: [ :n | dir _ ServerDirectory serverNamed: n. (dir isKindOf: SuperSwikiServer) ifTrue: [ nameToShow _ n. dirList add: ((dir directoryWrapperClass with: dir name: nameToShow model: self) balloonText: dir realUrl) ]. ]. {Project squeakletDirectory} do: [ :each | dirList add: (FileDirectoryWrapper with: each name: each localName model: self) ]. ^dirList! ! !Project methodsFor: 'file in/out' stamp: 'RAA 2/19/2001 07:37'! squeakletDirectory ^self class squeakletDirectory! ! !Project class methodsFor: 'squeaklet on server' stamp: 'RAA 2/19/2001 07:37'! squeakletDirectory | squeakletDirectoryName | squeakletDirectoryName _ 'Squeaklets'. (FileDirectory default directoryExists: squeakletDirectoryName) ifFalse: [ FileDirectory default createDirectory: squeakletDirectoryName ]. ^FileDirectory default directoryNamed: squeakletDirectoryName! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 07:50'! bestAccessToFileName: aFileName andDirectory: aDirectoryOrURL | localDir | ((localDir _ Project squeakletDirectory) fileExists: aFileName) ifTrue: [ ^{localDir readOnlyFileNamed: aFileName. localDir} ]. (aDirectoryOrURL isKindOf: String) ifTrue: [ ^{(Project serverFileFromURL: aDirectoryOrURL) asStream. nil} ]. ^{aDirectoryOrURL oldFileNamed: aFileName. aDirectoryOrURL} ! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 08:20'! installRemoteNamed: remoteFileName from: aServer named: otherProjectName in: currentProject | fileAndDir | "Find the current ProjectViewMorph, fetch the project, install in ProjectViewMorph without changing size, and jump into new project." fileAndDir _ self bestAccessToFileName: remoteFileName andDirectory: aServer. ProgressNotification signal: '1:foundMostRecent'. ^self openName: remoteFileName stream: fileAndDir first fromDirectory: fileAndDir second withProjectView: (currentProject findProjectView: otherProjectName). ! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 08:20'! openFromDirectory: aDirectory andFileName: aFileName | fileAndDir | fileAndDir _ self bestAccessToFileName: aFileName andDirectory: aDirectory. ComplexProgressIndicator new targetMorph: nil; historyCategory: 'project loading'; withProgressDo: [ self openName: aFileName stream: fileAndDir first fromDirectory: fileAndDir second withProjectView: nil. ]! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 08:22'! openFromFile: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView self error: 'use #openFromFile:fromDirectory:withProjectView:' ! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 08:24'! openName: aFileName stream: preStream fromDirectory: aDirectoryOrNil withProjectView: existingView "Reconstitute a Morph from the selected file, presumed to be represent a Morph saved via the SmartRefStream mechanism, and open it in an appropriate Morphic world." | morphOrList proj trusted localDir | preStream ifNil: [ ProgressNotification signal: '9999 about to enter project'. "the hard part is over" ^self inform: 'It looks like a problem occurred while getting this project. It may be temporary, so you may want to try again,' ]. ProgressNotification signal: '2:fileSizeDetermined ',preStream size printString. trusted _ SecurityManager default positionToSecureContentsOf: preStream. trusted ifFalse:[(SecurityManager default enterRestrictedMode) ifFalse:[ (preStream respondsTo: #close) ifTrue:[preStream close]. ^self]]. localDir _ Project squeakletDirectory. aFileName ifNotNil: [ (aDirectoryOrNil isNil or: [aDirectoryOrNil pathName ~= localDir pathName]) ifTrue: [ localDir deleteFileNamed: aFileName. (localDir fileNamed: aFileName) nextPutAll: preStream contents; close. ]. ]. morphOrList _ preStream asUnZippedStream. preStream sleep. "if ftp, let the connection close" ProgressNotification signal: '3:unzipped'. morphOrList _ morphOrList fileInObjectAndCode. ProgressNotification signal: '4:filedIn'. ProgressNotification signal: '9999 about to enter project'. "the hard part is over" (morphOrList isKindOf: ImageSegment) ifTrue: [ proj _ morphOrList arrayOfRoots detect: [:mm | mm class == Project] ifNone: [^self inform: 'No project found in this file']. proj versionFrom: preStream. proj lastDirectory: aDirectoryOrNil. CurrentProjectRefactoring currentBeParentTo: proj. existingView ifNil: [ Smalltalk isMorphic ifTrue: [ proj createViewIfAppropriate. ] ifFalse: [ ProjectView openAndEnter: proj. "Note: in MVC we get no further than the above" ]. ] ifNotNil: [ (existingView project isKindOf: DiskProxy) ifFalse: [ existingView project changeSet name: ChangeSet defaultName ]. "proj changeSet name: otherProjectName." "<<< why would we need this?" (existingView owner isKindOf: SystemWindow) ifTrue: [ existingView owner model: proj ]. existingView project: proj. ]. ^ ProjectEntryNotification signal: proj ]. (morphOrList isKindOf: SqueakPage) ifTrue: [ morphOrList _ morphOrList contentsMorph ]. (morphOrList isKindOf: PasteUpMorph) ifFalse: [ ^ self inform: 'This is not a PasteUpMorph or exported Project.' ]. (Project newMorphicOn: morphOrList) enter ! ! !ProjectLoading class methodsFor: 'as yet unclassified' stamp: 'RAA 2/19/2001 08:21'! thumbnailFromUrl: urlString | fileName fileAndDir | "Load the project, and make a thumbnail to it in the current project. ProjectLoading thumbnailFromUrl: 'http://www.squeak.org/Squeak2.0/2.7segments/SqueakEasy.extSeg'. " fileName _ (urlString findTokens: '/') last. fileAndDir _ self bestAccessToFileName: fileName andDirectory: urlString. Project canWeLoadAProjectNow ifFalse: [^ self]. ComplexProgressIndicator new targetMorph: nil; historyCategory: 'project loading'; withProgressDo: [ self openName: fileName stream: fileAndDir first fromDirectory: fileAndDir second withProjectView: nil. ] ! !