[FIX] RenameWithoutPlayer
Joshua Channing Gargus
schwa at cc.gatech.edu
Fri Dec 29 03:15:41 UTC 2000
>From the preamble:
Fixes an error that occurred when trying to rename a morph
that didn't already have a player.
Fixes another error that occured when I had a viewer open
on a non-morph.
Joshua
-------------- next part --------------
'From Squeak2.9alpha of 13 June 2000 [latest update: #3144] on 28 December 2000 at 10:05:38 pm'!
"Change Set: RenameWithoutPlayer
Date: 28 December 2000
Author: Joshua Gargus
Fixes an error that occurred when trying to rename a morph that didn't already have a player.
Fixes another error that occured when I had a viewer open on a non-morph."!
!Morph methodsFor: 'naming' stamp: 'jcg 12/28/2000 21:53'!
renameTo: aName
"Set Player name in costume. Update Viewers. Fix all tiles (old style). fix References. New tiles: recompile, and recreate open scripts. If coming in from disk, and have name conflict, References will already have new name."
| aPresenter putInViewer aPasteUp renderer oldKey assoc classes oldName |
oldName _ self knownName.
(renderer _ self topRendererOrSelf) setNameTo: aName.
putInViewer _ false.
((aPresenter _ self presenter) isNil or: [renderer player isNil]) ifFalse:
[putInViewer _ aPresenter currentlyViewing: renderer player.
putInViewer!
!
!
ifTrue: [
renderer player viewerFlapTab hibernate]]. "empty it temporarily"
(aPasteUp _ self topPasteUp) ifNotNil:
[aPasteUp allTileScriptingElements do: [:m | m bringUpToDate]].
putInViewer ifTrue: [aPresenter viewMorph: self]. "recreate my viewer"
"fix References dictionary. See restoreReferences to know why oldKey is
already aName, but oldName is the old name."
oldKey _ References keyAtIdentityValue: renderer player ifAbsent: [^ aName].
assoc _ References associationAt: oldKey.
oldKey = aName ifFalse: ["normal rename"
assoc key: aName.
References rehash].
"Force strings in tiles to be remade with new name. New tiles only."
(aPasteUp valueOfProperty: #universalTiles ifAbsent: [false]) ifFalse: [^ aName].
classes _ (Smalltalk allCallsOn: assoc) collect: [:classAndMethod |
(classAndMethod findTokens: Character separators) first asSymbol].
(classes asSet) do: [:clsName |
(Smalltalk at: clsName) replaceSilently: oldName to: aName].
"replace in !
!
!
text body of all methods. Can be wrong!!"
"Redo the tiles that are showing"
aPasteUp allTileScriptingElements do: [:mm | "just ScriptEditorMorphs"
(mm isKindOf: ScriptEditorMorph) ifTrue: [
((mm playerScripted class compiledMethodAt: mm scriptName) hasLiteral: assoc)
ifTrue: [mm hibernate; unhibernate]]].
^ aName
! !
!TileMorph methodsFor: 'initialization' stamp: 'jcg 12/28/2000 22:04'!
bringUpToDate
| newLabel |
"Scott's extentions to EToy mean that actualObject need not be a morph anymore."
(type == #objRef and: [actualObject isKindOf: Morph]) ifTrue:
[newLabel _ actualObject externalName.
self isPossessive ifTrue:
[newLabel _ newLabel, '''s'].
self line1: newLabel]
! !
More information about the Squeak-dev
mailing list
|