[squeak-dev] The Trunk: Tools-mt.1080.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Dec 6 16:27:21 UTC 2021


Marcel Taeumel uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-mt.1080.mcz

==================== Summary ====================

Name: Tools-mt.1080
Author: mt
Time: 6 December 2021, 5:27:16.648211 pm
UUID: 8a35bfc8-a273-554d-85a9-27d79f60b98f
Ancestors: Tools-mt.1079

Drop the property protocol from Workspace again since this looks like a "premature abstraction" or wrong use of the "variable extension" pattern, given its currently known scenarios. Instead, use regular instance variables.

See discussion here: http://lists.squeakfoundation.org/pipermail/squeak-dev/2021-November/217129.html

=============== Diff against Tools-mt.1079 ===============

Item was changed:
+ (PackageInfo named: 'Tools') preamble: '(Workspace instVarNames includes: #windowTitle)
+ 	ifFalse: [Workspace addInstVarName: #windowTitle].
+ (Workspace instVarNames includes: #fileDirectory)
+ 	ifFalse: [Workspace addInstVarName: #fileDirectory].
+ (Workspace instVarNames includes: #fileLineEndConvention)
+ 	ifFalse: [Workspace addInstVarName: #fileLineEndConvention].
+ 
+ Workspace allInstancesDo: [:workspace | 
+ 	workspace instVarNamed: #windowTitle
+ 		put: (workspace valueOfProperty: #windowTitle).
+ 	workspace instVarNamed: #fileDirectory
+ 		put: (workspace valueOfProperty: #fileDirectory).
+ 	workspace instVarNamed: #fileLineEndConvention
+ 		put: (workspace valueOfProperty: #fileLineConversion)].
+ '!
- (PackageInfo named: 'Tools') preamble: 'Project current isMorphic ifTrue: [
- 	| windows |
- 	windows := SystemWindow
- 		windowsIn: Project current world
- 		satisfying: [:window | window visible and: [window model isKindOf: Inspector] ].
- 	Smalltalk globals
- 		at: #ObjectsUnderInspection
- 		put: (windows collect: [:ea | ea model object]).
- 	windows do: [:window | [window delete] valueSupplyingAnswer: true]].'!

Item was changed:
  ----- Method: FileList>>viewContentsInWorkspace (in category 'own services') -----
  viewContentsInWorkspace
  	"View the contents of my selected file in a new workspace."
  	
+ 	| fileContents workspace lineEndConvention |
- 	| fileContents workspace lineConversion |
  	fileContents := self directory
  		readOnlyFileNamed: self fileName
  		do: [:fileStream |
  			fileStream
  				setConverterForCode;
  				wantsLineEndConversion: true.
+ 			lineEndConvention := fileStream detectLineEndConvention.
- 			lineConversion := fileStream detectLineEndConvention.
  			fileStream contents].		
  	workspace := (Project uiManager edit: fileContents label: nil shouldStyle: Workspace shouldStyle) model.
  	
  	"Remember certain information to allow edits in the same file."
  	workspace
  		windowTitle: (self directory localNameFor: self fileName);
  		fileDirectory: self directory;
+ 		fileLineEndConvention: lineEndConvention;
- 		setProperty: #fileLineConversion toValue: lineConversion;
  		saveContentsInFileOnAccept.
  !

Item was changed:
  StringHolder subclass: #Workspace
+ 	instanceVariableNames: 'bindings acceptDroppedMorphs acceptAction mustDeclareVariables shouldStyle environment windowTitle fileDirectory fileLineEndConvention'
- 	instanceVariableNames: 'bindings acceptDroppedMorphs acceptAction mustDeclareVariables shouldStyle environment'
  	classVariableNames: 'DeclareVariablesAutomatically EmbedTranscript FileOutFilePath FileOutOnAccept LookupPools ShouldStyle'
  	poolDictionaries: ''
  	category: 'Tools-Base'!
  
  !Workspace commentStamp: 'fbs 6/2/2012 20:46' prior: 0!
  A Workspace is a text area plus a lot of support for executable code.  It is a great place to execute top-level commands to compute something useful, and it is a great place to develop bits of a program before those bits get put into class methods.
  
  To open a new workspace, execute:
  
  	Workspace open
  
  
  A workspace can have its own variables, called "workspace variables", to hold intermediate results.  For example, if you type into a workspace "x := 5" and do-it, then later you could type in "y := x * 2" and y would become 10.
  
  Additionally, in Morphic, a workspace can gain access to morphs that are on the screen.  If acceptDroppedMorphs is turned on, then whenever a morph is dropped on the workspace, a variable will be created which references that morph.  This functionality is toggled with the window-wide menu of a workspace.
  
  
  The instance variables of this class are:
  
  	bindings  -  holds the workspace variables for this workspace
  
  	acceptDroppedMorphs - whether dropped morphs should create new variables!

Item was changed:
  ----- Method: Workspace>>fileDirectory (in category 'accessing') -----
  fileDirectory
  	"Answer the current directory for save-contents requests."
  	
+ 	^ fileDirectory ifNil: [FileDirectory default]!
- 	^ (self valueOfProperty: #fileDirectory) ifNil: [FileDirectory default]!

Item was changed:
  ----- Method: Workspace>>fileDirectory: (in category 'accessing') -----
  fileDirectory: aDirectory
  	"Do not save the default directory so that the image and its surrounding files can be moved across the disk."
  	
+ 	fileDirectory := aDirectory = FileDirectory default ifFalse: [aDirectory].!
- 	aDirectory = FileDirectory default
- 		ifTrue: [self removeProperty: #fileDirectory]
- 		ifFalse: [self setProperty: #fileDirectory toValue: aDirectory].!

Item was added:
+ ----- Method: Workspace>>fileLineEndConvention (in category 'accessing') -----
+ fileLineEndConvention
+ 
+ 	^ fileLineEndConvention!

Item was added:
+ ----- Method: Workspace>>fileLineEndConvention: (in category 'accessing') -----
+ fileLineEndConvention: aSymbol
+ 	"#cr, #lf, #crlf -- 'nil' means Squeak's default"
+ 
+ 	fileLineEndConvention := aSymbol.!

Item was removed:
- ----- Method: Workspace>>hasProperty: (in category 'binding - properties') -----
- hasProperty: aSymbol
- 
- 	| propertyValue |
- 	propertyValue := self valueOfProperty: aSymbol.
- 	propertyValue ifNil: [^ false].
- 	propertyValue == false ifTrue: [^ false].
- 	^ true!

Item was changed:
  ----- Method: Workspace>>initialize (in category 'initialize-release') -----
  initialize
  	
  	super initialize.
+ 	self resetBindings.
- 	bindings := Dictionary new.
  	acceptDroppedMorphs := false.
  	mustDeclareVariables := self class declareVariablesAutomatically not.
  	environment := Environment current!

Item was removed:
- ----- Method: Workspace>>removeProperty: (in category 'binding - properties') -----
- removeProperty: aSymbol
- 
- 	bindings removeKey: ('_', aSymbol) asSymbol ifAbsent: [].!

Item was changed:
  ----- Method: Workspace>>resetBindings (in category 'binding') -----
  resetBindings
- 	"Remove all bindings that are not prefixed with an $_. See #setProperty:toValue:."
  
+ 	bindings := Dictionary new.!
- 	bindings keysAndValuesRemove: [:key :value | key first ~= $_]!

Item was changed:
  ----- Method: Workspace>>saveContents:onFileNamed:accessMode: (in category 'user edits') -----
  saveContents: stringContents onFileNamed: fileName accessMode: accessMode
  	"Overwritten to set conversion rule of line-end character. See FileList >> #viewContentsInWorkspace."
  	
  	^ self
  		saveContents: stringContents
  		onFileNamed: fileName
  		accessMode: accessMode
  		workBlock: [:fileStream |
  			fileStream
+ 				lineEndConvention: self fileLineEndConvention;
- 				lineEndConvention: (self valueOfProperty: #fileLineConversion); "nil is fine here..."
  				nextPutAll: stringContents]!

Item was removed:
- ----- Method: Workspace>>setProperty:toValue: (in category 'binding - properties') -----
- setProperty: aSymbol toValue: anObject
- 
- 	anObject ifNil: [^ self removeProperty: aSymbol].
- 	bindings at: ('_', aSymbol) asSymbol put: anObject.!

Item was added:
+ ----- Method: Workspace>>setWindowTitle: (in category 'initialize-release') -----
+ setWindowTitle: aString
+ 	"Normalize window title to not expose file extension in regular workspaces. Do not tell the UI to avoid endless recursion; see #windowTitle: and #windowReqNewLabel:."
+ 	
+ 	| normalizedTitle |
+ 	normalizedTitle := ((aString includesSubstring: 'Workspace') and: [aString endsWithAnyOf: #('.text' '.txt')])
+ 		ifTrue: [aString copyFrom: 1 to: (aString lastIndexOf: $.) - 1]
+ 		ifFalse: [aString].
+ 
+ 	windowTitle := normalizedTitle.!

Item was removed:
- ----- Method: Workspace>>valueOfProperty: (in category 'binding - properties') -----
- valueOfProperty: aSymbol
- 
- 	^ self valueOfProperty: aSymbol ifAbsent: nil!

Item was removed:
- ----- Method: Workspace>>valueOfProperty:ifAbsent: (in category 'binding - properties') -----
- valueOfProperty: aSymbol ifAbsent: aBlock
- 
- 	^ bindings at: ('_', aSymbol) asSymbol ifAbsent: aBlock!

Item was changed:
  ----- Method: Workspace>>windowReqNewLabel: (in category 'user edits') -----
  windowReqNewLabel: newLabel
  	"The user has edited the window label. Remember for a later save-to-file request. See #defaultFileNameForSave."
  	
+ 	self setWindowTitle: newLabel.
- 	self setProperty: #windowTitle toValue: newLabel.
  	^ true!

Item was changed:
  ----- Method: Workspace>>windowTitle (in category 'accessing') -----
  windowTitle
  
+ 	^ windowTitle ifNil: ['Workspace']!
- 	^ (self valueOfProperty: #windowTitle) ifNil: ['Workspace']!

Item was changed:
  ----- Method: Workspace>>windowTitle: (in category 'accessing') -----
  windowTitle: aString
- 	"Normalize window title to not expose file extension in regular workspaces."
  	
+ 	self setWindowTitle: aString.
- 	| normalizedTitle |
- 	normalizedTitle := ((aString includesSubstring: 'Workspace') and: [aString endsWithAnyOf: #('.text' '.txt')])
- 		ifTrue: [aString copyFrom: 1 to: (aString lastIndexOf: $.) - 1]
- 		ifFalse: [aString].
- 
- 	self setProperty: #windowTitle toValue: normalizedTitle.
  	self changed: #windowTitle.!

Item was changed:
+ (PackageInfo named: 'Tools') postscript: 'Workspace allInstances do: [:workspace |
+ 	(workspace instVarNamed: #bindings)
+ 		removeKey: #''_fileDirectory'' ifAbsent: nil;
+ 		removeKey: #''_windowTitle'' ifAbsent: nil;
+ 		removeKey: #''_fileLineConversion'' ifAbsent: nil].'!
- (PackageInfo named: 'Tools') postscript: 'ChangeSorter allSubInstancesDo: [:sorter |
- 	(sorter instVarNamed: ''contentsAreStyleable'') ifNil: [
- 		sorter instVarNamed: ''contentsAreStyleable'' put: true]].
- 
- "Convert existing properties from Morphic windows to the model. For MVC compatibility."
- Workspace allInstancesDo: [:workspace | 
- 	workspace containingWindow ifNotNil: [:window |
- 		(window valueOfProperty: #myDir) ifNotNil: [:directory |
- 			workspace setProperty: #fileDirectory toValue: directory].
- 		(window valueOfProperty: #lineConversion) ifNotNil: [:symbol |
- 			workspace setProperty: #fileLineConversion toValue: symbol].
- 		workspace setProperty: #windowTitle toValue: window label].
- 	(workspace acceptAction notNil and: [workspace acceptAction home selector = #open])
- 		ifTrue: [workspace appendContentsToFileOnAccept]].'!



More information about the Squeak-dev mailing list