Thanks, this seems to work:
defaultSpec
| layout |
layout := SpecLayout composed.
self pluginClasses do: [ :c |
layout add: {#model. #class. #pluginOf:. c. #defaultSpec} ].
^ layout.
plugin code on the instance side looks like this:
defaultSpec
^ SpecLayout composed
newRow:[: r |
r add: #finderButtonModel;
add: #browserButtonModel]
height: 25.
-- Pavel
2013/10/4 Benjamin <[email protected]>:
> Since you are doing some really edge use of Spec,
> it's not covered by Spec easily.
>
> But if on you model you have a method returning your pluginClasses, you could
> do maybe:
>
> | layout |
> layout := SpecLayout composed.
> self pluginClasses do: [ :c |
> layout add: {#model. pluginOf:. c} ]
>
> I am not sure it works, but it worth a try :P
>
> Ben
>
> On Oct 4, 2013, at 9:28 PM, Pavel Krivanek <[email protected]> wrote:
>
>> This was the original code for the spec that embeds plugins. As you
>> can see, it had to use ugly addMorph:. I do not think that I need to
>> do something special. Has the current Spec a better way how to do
>> that?
>>
>> defaultSpec
>>
>> | spec |
>> spec := OrderedCollection with: #ContainerModel.
>> spec addAll: {#changeTableLayout.
>> #listDirection:. #topToBottom.
>> #hResizing:. #spaceFill.
>> #vResizing:. #spaceFill.}.
>> self pluginClasses do: [:c |
>> spec add: #addMorph:.
>> spec add: {(self pluginOf: c) defaultSpec}].
>> ^ spec asArray.
>>
>> 2013/10/4 Pavel Krivanek <[email protected]>:
>>> In other words... I have a model that has some plugins. I need to
>>> generate a spec that embeds specs generated for each plugin. Models
>>> for this embedded specs must be the plugins, not the original model.
>>>
>>> -- Pavel
>>>
>>> 2013/10/4 Pavel Krivanek <[email protected]>:
>>>> well, and the version with "SpecLayout composed" when I do not need
>>>> direct fractions?
>>>>
>>>> ^ SpecLayout composed
>>>> newRow:[: r |
>>>> r add: #finderButtonModel]
>>>> height: 25
>>>>
>>>> How to send #finderButtonModel to different object than SpecInterpreter
>>>> model?
>>>>
>>>> -- Pavel
>>>>
>>>> 2013/10/4 Benjamin <[email protected]>:
>>>>> ^{ #ContainerModel.
>>>>>
>>>>> #vShrinkWrap.
>>>>>
>>>>> #add:. {{self. #finderButtonModel}.
>>>>>
>>>>> #layout:. #(FrameLayout
>>>>>
>>>>> rightFraction: 0.125)}.
>>>>>
>>>>> #add:. {{self. #browserButtonModel}.
>>>>>
>>>>> #layout:. #(FrameLayout
>>>>>
>>>>> leftFraction: 0.125
>>>>> rightFraction: 0.25)}}
>>>>>
>>>>> This should work, but looks strange though :P
>>>>>
>>>>> Ben
>>>>>
>>>>> On Oct 4, 2013, at 8:13 PM, Pavel Krivanek <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Ben,
>>>>>
>>>>> how now should look code like this:
>>>>>
>>>>> defaultSpec
>>>>>
>>>>> ^{ #ComposableSpec.
>>>>> #vResizing:. #shrinkWrap.
>>>>> #add:. {{self. #finderButtonModel}.
>>>>> #layout:. #(FrameLayout
>>>>> rightFraction: 0.125)}.
>>>>> #add:. {{self. #browserButtonModel}.
>>>>> #layout:. #(FrameLayout
>>>>> leftFraction: 0.125
>>>>> rightFraction: 0.25)}}
>>>>>
>>>>> -- Pavel
>>>>>
>>>>> 2013/10/4 Benjamin <[email protected]>:
>>>>>
>>>>> For Spec users:
>>>>>
>>>>> The change is mostly backward compatible :)
>>>>> 2 things really changed:
>>>>> - direct access to a model's widget is not returning what it used to
>>>>> return.
>>>>> This is done on purpose since
>>>>> it's very often a bad idea to directly access the widget.
>>>>> - some behaviour on trees are now only available after the tree build.
>>>>> This
>>>>> is because some properties
>>>>> have been moved on the adapter directly, which is reachable only after the
>>>>> model build.
>>>>> You can use `whenBuiltDo:` to add post-build actions.
>>>>>
>>>>> Enjoy this new Spec :P
>>>>>
>>>>> Ben
>>>>>
>>>>> On Oct 4, 2013, at 2:31 PM, Marcus Denker <[email protected]> wrote:
>>>>>
>>>>> 30448
>>>>> -----
>>>>>
>>>>> 11740 Remove Morphic dependency from Spec
>>>>> https://pharo.fogbugz.com/f/cases/11740
>>>>>
>>>>> A Huge change from Ben...
>>>>>
>>>>> Diff information:
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Tools-MarcusDenker.1292.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Tabs-MarcusDenker.33.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Widgets-MarcusDenker.265.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Tools-MarcusDenker.150.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Tests-MarcusDenker.35.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-MorphicAdapters-MarcusDenker.9.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-PolyWidgets-MarcusDenker.7.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Layout-MarcusDenker.58.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Inspector-MarcusDenker.102.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Examples-MarcusDenker.48.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Debugger-MarcusDenker.163.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Core-MarcusDenker.175.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Builder-MarcusDenker.43.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Bindings-MarcusDenker.35.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/NautilusRefactoring-MarcusDenker.126.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Spec-Adapters-MarcusDenker.3.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Manifest-CriticBrowser-MarcusDenker.124.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/Keymapping-Tools-Spec-MarcusDenker.19.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/KeyChain-MarcusDenker.58.diff
>>>>> http://smalltalkhub.com/mc/Pharo/Pharo30/main/HudsonBuildTools20-MarcusDenker.45.diff
>>>>>
>>>>>
>>>>>
>>>>>
>>
>
>