With Spec, it is really easy to make some simple widgets:

"you have a class and a method?"
class:=Morph.
method:=class>>#openInWorld.
"want some textmorp?"
code := TextModel new.
code text:method sourceCode.
"with styling?"
code aboutToStyle:true.
"in context of the class"
code behavior:class.
"do it!"
code openWithSpec.
"more? save on accept..."
code acceptBlock:[:text |
    class compile:text notifying:nil.
    ].



Composing models:

class:=Morph.
method:=class>>#openInWorld.
composed:= DynamicComposableModel new.
composed instantiateModels: #(code TextModel method TextInputFieldModel).
composed code text:method sourceCode.
composed method text: method selector asString.
composed code aboutToStyle:true.
composed code behavior:class.
composed code acceptBlock:[:text |
    class compile:text notifying:nil.
    ].
composed method acceptBlock:[:text |
    method:=class methodDict at:text asSymbol.
composed code text:method sourceCode.
    ].
composed openWithSpecLayout:(
SpecLayout composed
newColumn:[:r | r
add: #method height:25;
add: #code];
yourself).


or search for DynamicComposableModel in this mailing list or
look at some other basic Spec examples in Pharo:
    | cb |
    cb := ClassMethodBrowser new.
    cb openWithSpec.
    cb classes: Smalltalk allClasses.


    | si |
    si := MethodBrowser new.
    si openWithSpec.
    si methods: Object methodDict values








2014-05-15 9:29 GMT+02:00 Hilaire Fernandes <hilaire.fernan...@gmail.com>:

> Thierry,
>
> I was not aware it could be that short. Yes it will be nice.
> All in all:
> - one GUI tool to edit an existing script (so no visibility on the other
> methods of the class)
> - one GUI tool to create a method (with visibility to the other method
> of the class, as possible examples)
>
>
> Hilaire
>
> Le 15/05/2014 09:18, Goubier Thierry a écrit :
>
> > Have you considered controlling the user experience directly to let him
> > focus only on the method to create or edit?
> >
> > Creating a text editor window in coding mode with the ability to edit or
> > create a method in a preset class is not much work; I'd say around 20
> > lines with the default menu and an accept which compiles.
> >
> > If you want complete control on the menu (i.e. a bit more polish than
> > the default and control over which shortcuts are active), I can extract
> > what I've done for mine: it's a minimal command objects API to couple
> > menus and shortcuts inspired by the one of the OmniBrowser (of Pharo
> > 1.4). In there, a typical command with its
> > shortcut/label/icon/activation status is about five lines long.
>
>
> --
> Dr. Geo http://drgeo.eu
>
>
>

Reply via email to