'From Squeakeasy0.0 of 13 May 2003 [latest update: #109] on 8 November 2003 at 2:38:17 pm'! "Change Set: wkspcFromFile-sw Date: 8 November 2003 Author: Scott Wallace Adds a file-list service affording the opening of a workspace on the contents of any file. Adds a command to the Workspace menu affording the appending of the contents of any file to the workspace."! !FileList methodsFor: 'file list menu' stamp: 'sw 11/8/2003 13:32'! itemsForAnyFile "Answer a list of universal services that could apply to any file" | services | services := OrderedCollection new: 4. services add: self serviceCopyName. services add: self serviceRenameFile. services add: self serviceDeleteFile. services add: self serviceViewContentsInWorkspace. ^ services! ! !FileList methodsFor: 'own services' stamp: 'sw 11/8/2003 13:34'! serviceViewContentsInWorkspace "Answer a service for viewing the contents of a file in a workspace" ^ (SimpleServiceEntry provider: self label: 'workspace with contents' selector: #viewContentsInWorkspace) description: 'open a new Workspace whose contents are set to the contents of this file'! ! !FileList methodsFor: 'own services' stamp: 'sw 11/8/2003 13:39'! viewContentsInWorkspace "View the contents of my selected file in a new workspace" | aString aFileStream aName | aString _ (aFileStream _ directory readOnlyFileNamed: self fullName) contentsOfEntireFile. aName _ aFileStream localName. aFileStream close. (Workspace new contents: aString) openLabel: 'Workspace from ', aName! ! !Workspace methodsFor: 'menu commands' stamp: 'sw 11/8/2003 13:30'! addModelItemsToWindowMenu: aMenu "Add model-related items to the supplied window menu" aMenu addLine. aMenu add: 'save contents to file...' target: self action: #saveContentsInFile. aMenu add: 'append contents of file...' target: self action: #appendContentsOfFile. aMenu addLine. aMenu addUpdating: #acceptDroppedMorphsWording target: self action: #toggleDroppingMorphForReference! ! !Workspace methodsFor: 'menu commands' stamp: 'sw 11/8/2003 14:24'! appendContentsOfFile "Prompt for a file, and if one is obtained, append its contents to the contents of the receiver. Caution: as currently implemented this abandons any custom style information previously in the workspace. Someone should fix this. Also, for best results you should accept the contents of the workspace before requesting this." | aFileStream | (aFileStream _ FileList2 modalFileSelector) ifNil: [^ self]. contents _ (contents ifNil: ['']) asString, aFileStream contentsOfEntireFile. aFileStream close. self changed: #contents! !