[etoys-dev] Etoys: Etoys-Richo.103.mcz

karl ramberg karlramberg at gmail.com
Mon Feb 6 16:13:13 EST 2012


Nice.

Karl

On Mon, Feb 6, 2012 at 9:17 PM,  <commits at source.squeak.org> wrote:
> Ricardo Moran uploaded a new version of Etoys to project Etoys:
> http://source.squeak.org/etoys/Etoys-Richo.103.mcz
>
> ==================== Summary ====================
>
> Name: Etoys-Richo.103
> Author: Richo
> Time: 6 February 2012, 5:16:57 pm
> UUID: 84503c98-7c83-064f-957f-5bacf093d22e
> Ancestors: Etoys-kfr.102
>
> Sixteen items for Squeakland 2012:
>
> 11. On Add Variable: Show options for value type - to make it easier to discover different types besides number (Ex: player, color, etc).
>
> =============== Diff against Etoys-kfr.102 ===============
>
> Item was changed:
>  ----- Method: Player>>addInstanceVariable (in category 'slots-user') -----
>  addInstanceVariable
>        "Offer the user the opportunity to add an instance variable, and if he goes through with it, actually add it."
>
>        | itsName initialValue typeChosen usedNames initialAnswer setterSelector originalString |
> +       usedNames := self class instVarNames.
> -       usedNames _ self class instVarNames.
>
> +       initialAnswer := Utilities keyLike: ('var' translated, (usedNames size + 1) asString)  satisfying: [:aKey | (usedNames includes: aKey) not].
> -       initialAnswer _ Utilities keyLike: ('var' translated, (usedNames size + 1) asString)  satisfying: [:aKey | (usedNames includes: aKey) not].
>
> +       originalString := FillInTheBlank request: 'name for new variable: ' translated initialAnswer: initialAnswer.
> -       originalString _ FillInTheBlank request: 'name for new variable: ' translated initialAnswer: initialAnswer.
>  Cursor wait showWhile: [
>        originalString isEmptyOrNil ifTrue: [^ self].
> +       itsName := ScriptingSystem acceptableSlotNameFrom: originalString forSlotCurrentlyNamed: nil asSlotNameIn: self world: self costume world.
> -       itsName _ ScriptingSystem acceptableSlotNameFrom: originalString forSlotCurrentlyNamed: nil asSlotNameIn: self world: self costume world.
>
>        itsName size == 0 ifTrue: [^ self].
>        self assureUniClass.
> +       typeChosen := self askUserForNewTypeFor: itsName.
> -       typeChosen _ self initialTypeForSlotNamed: itsName.
>        self slotInfo at: itsName put: (SlotInformation new initialize type: typeChosen).
> +       initialValue := self initialValueForSlotOfType: typeChosen.
> -       initialValue _ self initialValueForSlotOfType: typeChosen.
>        self addInstanceVarNamed: itsName withValue: initialValue.
>        self compileInstVarAccessorsFor: itsName.
> +       setterSelector := Utilities setterSelectorFor: itsName.
> -       setterSelector _ Utilities setterSelectorFor: itsName.
>        ((self class allSubInstances copyWithout: self) reject: [:e | e isSequentialStub]) do:
>                [:anInstance | anInstance perform: setterSelector with: initialValue].
>        self regenerateScripts.
> +       self updateAllViewersAndForceToShow: ScriptingSystem nameForInstanceVariablesCategory.
> -       self updateAllViewersAndForceToShow: ScriptingSystem nameForInstanceVariablesCategory
>  ]!
>
> Item was added:
> + ----- Method: Player>>askUserForNewTypeFor: (in category 'slots-user') -----
> + askUserForNewTypeFor: slotName
> +       | typeChoices menuCaption |
> +       typeChoices := Vocabulary typeChoices asOrderedCollection.
> +       [self costume renderedMorph defaultPatch]
> +               on:Exception
> +               do:[ typeChoices remove: #Patch ifAbsent: [typeChoices]].
> +       menuCaption := 'Choose the TYPE
> + for {1}
> + ' translated, slotName, '
> + (currently {2})' translated format: {slotName. (self slotInfoAt: slotName) type translated}.
> +       ^ (SelectionMenu
> +                       labelList: (typeChoices collect: [:t | t translated])
> +                       lines: #()
> +                       selections: typeChoices)
> +                               startUpWithCaption: menuCaption.!
>
> Item was changed:
>  ----- Method: Player>>chooseSlotTypeFor: (in category 'slots-user') -----
>  chooseSlotTypeFor: aGetter
>        "Let the user designate a type for the slot associated with the given getter"
>
> +       | typeChosen slotName |
> +       slotName := Utilities inherentSelectorForGetter: aGetter.
> +       typeChosen := self askUserForNewTypeFor: slotName.
> -       | typeChoices typeChosen slotName |
> -       slotName _ Utilities inherentSelectorForGetter: aGetter.
> -       typeChoices _ Vocabulary typeChoices asOrderedCollection.
> -       [self costume renderedMorph defaultPatch] on:Exception do:[ typeChoices remove: #Patch ifAbsent: [typeChoices]].
> -       typeChosen _ (SelectionMenu labelList: (typeChoices collect: [:t | t translated]) lines: #() selections: typeChoices) startUpWithCaption:
> -               ('Choose the TYPE
> - for {1}
> - ' translated, slotName, '
> - (currently {2})' translated format: {slotName. (self slotInfoAt: slotName) type translated}).
>        typeChosen isEmptyOrNil ifTrue: [^ self].
>        (self typeForSlot: slotName) capitalized = typeChosen ifTrue: [^ self].
>
>        (self slotInfoAt: slotName) type: typeChosen.
>        self class allInstancesDo:   "allSubInstancesDo:"
>                [:anInst | anInst instVarNamed: slotName asString put:
>                        (anInst valueOfType: typeChosen from: (anInst instVarNamed: slotName))].
>        self updateAllViewers.  "does siblings too"
>        self changeTypesInWatchersOf: slotName.  "does siblings too"
>
>  !
>
> _______________________________________________
> etoys-dev mailing list
> etoys-dev at squeakland.org
> http://lists.squeakland.org/mailman/listinfo/etoys-dev


More information about the etoys-dev mailing list