Custom Glamour browser for Dr. Geo scripting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Custom Glamour browser for Dr. Geo scripting

HilaireFernandes
Hi,

I try to build a dedicated browser for user scripting on DrGeo. I am
learning from the Deep into Pharo Glamour chapter, extending the given
example.

Regarding the method category pane, I need both instance and class side,
so I write it like this:

categoriesIn: constructor
constructor list
   title: 'Methods';
   display: [ :scriptClass | scriptClass organization categories].
constructor list
   title: 'Script data';
   display: [ :scriptClass | scriptClass class organization categories]


The browser is defined as:


buildBrowser
   browser := GLMTabulator new.
   browser
      column: #scripts;
      column: #categories;
      column: #methods.
browser transmit to: #scripts; andShow: [ :a | self scriptsIn: a ].
browser transmit from: #scripts; to: #categories; andShow: [ :a | self
categoriesIn: a ].
browser transmit from: #scripts; from: #categories; to: #methods;
   andShow: [:a | self methodsIn: a  ].
browser transmit from: #scripts; from: #categories; to: #methods;
   andShow: [:a | self classMethodsIn: a  ].
browser transmit from: #scripts; toOutsidePort: #selectedScript.
browser transmit from: #methods; toOutsidePort: #selectedMethod.
^ browser


but something is missing to get the listed method right depending on the
category is instance or class side. I don't how to do it.

Any tips?

Thanks

Hilaire

--
Dr. Geo
http://drgeo.eu


Reply | Threaded
Open this post in threaded view
|

Re: Custom Glamour browser for Dr. Geo scripting

HilaireFernandes
I extended the browser definition with:

    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a :b |  a isMeta not ];
        andShow: [:a | self methodsIn: a  ].
    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a | a isMeta ];
        andShow: [:a | self classMethodsIn: a  ].


However it does not work as #when: message always receive a class, so
the wrong methods a re list in the method pane.

I enclosed a Fileout of the browser. It works independently of DrGeo.
When one select class methods, still the instance methods are displayed
in right most pane.

Any tips?

Thanks

Hilaire


Le 29/06/2017 à 14:59, Hilaire a écrit :
> but something is missing to get the listed method right depending on the
> category is instance or class side. I don't how to do it.

--
Dr. Geo
http://drgeo.eu


DrGScriptBrowser.st (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Custom Glamour browser for Dr. Geo scripting

Nicolai Hess-3-2


2017-06-30 9:55 GMT+02:00 Hilaire <[hidden email]>:
I extended the browser definition with:

    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a :b |  a isMeta not ];
        andShow: [:a | self methodsIn: a  ].
    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a | a isMeta ];
        andShow: [:a | self classMethodsIn: a  ].


However it does not work as #when: message always receive a class, so
the wrong methods a re list in the method pane.

I enclosed a Fileout of the browser. It works independently of DrGeo.
When one select class methods, still the instance methods are displayed
in right most pane.

Any tips?

I don't have a solution. I just want to make more clear what the problem is.
See attached screenshot.
The question is, is it possible to make the population of the "methods" list
dependent of the focused "Instance Methods"/"Class Methods" pane ?

I tried to wire a "#focus" port, but I don't think the "categories"-pane exports
any port that could be used to distinguish between the selected tabs.




 

Thanks

Hilaire


Le 29/06/2017 à 14:59, Hilaire a écrit :
> but something is missing to get the listed method right depending on the
> category is instance or class side. I don't how to do it.

--
Dr. Geo
http://drgeo.eu



panes.png (27K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Custom Glamour browser for Dr. Geo scripting

Juraj Kubelka
Hi,

I am able to produce this: 

-=-=-=-
browser := GLMTabulator new
column: #one;
column: #two;
column: #three;
yourself.
browser transmit to: #one; andShow: [ :composite |
composite fastList ].

browser transmit from: #one; to: #two; andShow: [ :composite |
composite fastList 
title: [ 'Instance' translated ];
display: [ :aClass | aClass methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ].
composite fastList 
title: [ 'Class side' translated ];
display: [ :aClass | aClass class methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ].
composite onChangeOfPort: #activePresentation act: [ :presentation | 
(presentation pane port: #activePresentation) value
ifNotNil: [ :activePresentation | 
self inform: activePresentation printString.
self inform: activePresentation selection ] ] ].

browser transmit 
from: #two; to: #three; 
andShow: [ :composite | composite text 
display: [ :aCompiledMethod | aCompiledMethod sourceCode ] ].


browser openOn: Collection allSubclasses.
-=-=-=-

But I do not know how to change the column #three, because the selection is shared between the two lists.

I hope it helps and someone else can improve it :-) 

Cheers,
Juraj




El 01-07-2017, a las 10:48, Nicolai Hess <[hidden email]> escribió:



2017-06-30 9:55 GMT+02:00 Hilaire <[hidden email]>:
I extended the browser definition with:

    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a :b |  a isMeta not ];
        andShow: [:a | self methodsIn: a  ].
    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a | a isMeta ];
        andShow: [:a | self classMethodsIn: a  ].


However it does not work as #when: message always receive a class, so
the wrong methods a re list in the method pane.

I enclosed a Fileout of the browser. It works independently of DrGeo.
When one select class methods, still the instance methods are displayed
in right most pane.

Any tips?

I don't have a solution. I just want to make more clear what the problem is.
See attached screenshot.
The question is, is it possible to make the population of the "methods" list
dependent of the focused "Instance Methods"/"Class Methods" pane ?

I tried to wire a "#focus" port, but I don't think the "categories"-pane exports
any port that could be used to distinguish between the selected tabs.




 

Thanks

Hilaire


Le 29/06/2017 à 14:59, Hilaire a écrit :
> but something is missing to get the listed method right depending on the
> category is instance or class side. I don't how to do it.

--
Dr. Geo
http://drgeo.eu


<panes.png>

Reply | Threaded
Open this post in threaded view
|

Re: Custom Glamour browser for Dr. Geo scripting

Andrei Chis
Hi,

If I understood the issue correctly then the script below should address it.
It starts from the solution Juraj proposed but wraps each  presentation in a wrapper.
The script is not that obvious as this is not really a use case glamour supports out of the box.
Also in glamour multiple presentations displayed within a composite share the selection. To avoid that they need to be wrapped. The simplest solution is to use a GLMWrapper.

-=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=-

browser := GLMTabulator new
column: #one;
column: #two;
column: #three;
yourself.
browser transmit to: #one; andShow: [ :composite |
composite fastList ].

browser transmit from: #one; to: #two; andShow: [ :composite |
composite wrapper 
title: [ 'Instance' translated ];
show: [ :wrapper |
wrapper fastList 
display: [ :aClass | aClass methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ] ].
composite wrapper 
title: [ 'Class side' translated ];
show: [ :wrapper |
wrapper fastList 
display: [ :aClass | aClass class methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ] ].
composite onChangeOfPort: #activePresentation act: [ :presentation | 
(presentation pane port: #activePresentation) value
ifNotNil: [ :activePresentation | 
((browser paneNamed: #two) port: #selection) value: (activePresentation defaultPane port: #selection) value ] ] ].

browser transmit 
from: #two; to: #three; 
andShow: [ :composite | composite text 
display: [ :aCompiledMethod | aCompiledMethod sourceCode ] ].

browser openOn: Collection allSubclasses.
-=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=-

Cheers,
Andrei

On Sat, Jul 1, 2017 at 4:46 PM, Juraj Kubelka <[hidden email]> wrote:
Hi,

I am able to produce this: 

-=-=-=-
browser := GLMTabulator new
column: #one;
column: #two;
column: #three;
yourself.
browser transmit to: #one; andShow: [ :composite |
composite fastList ].

browser transmit from: #one; to: #two; andShow: [ :composite |
composite fastList 
title: [ 'Instance' translated ];
display: [ :aClass | aClass methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ].
composite fastList 
title: [ 'Class side' translated ];
display: [ :aClass | aClass class methods ];
format: [ :aCompiledMethod | aCompiledMethod selector asString ].
composite onChangeOfPort: #activePresentation act: [ :presentation | 
(presentation pane port: #activePresentation) value
ifNotNil: [ :activePresentation | 
self inform: activePresentation printString.
self inform: activePresentation selection ] ] ].

browser transmit 
from: #two; to: #three; 
andShow: [ :composite | composite text 
display: [ :aCompiledMethod | aCompiledMethod sourceCode ] ].


browser openOn: Collection allSubclasses.
-=-=-=-

But I do not know how to change the column #three, because the selection is shared between the two lists.

I hope it helps and someone else can improve it :-) 

Cheers,
Juraj




El 01-07-2017, a las 10:48, Nicolai Hess <[hidden email]> escribió:



2017-06-30 9:55 GMT+02:00 Hilaire <[hidden email]>:
I extended the browser definition with:

    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a :b |  a isMeta not ];
        andShow: [:a | self methodsIn: a  ].
    browser transmit
        from: #scripts;
        from: #categories;
        to: #methods;
        when: [ :a | a isMeta ];
        andShow: [:a | self classMethodsIn: a  ].


However it does not work as #when: message always receive a class, so
the wrong methods a re list in the method pane.

I enclosed a Fileout of the browser. It works independently of DrGeo.
When one select class methods, still the instance methods are displayed
in right most pane.

Any tips?

I don't have a solution. I just want to make more clear what the problem is.
See attached screenshot.
The question is, is it possible to make the population of the "methods" list
dependent of the focused "Instance Methods"/"Class Methods" pane ?

I tried to wire a "#focus" port, but I don't think the "categories"-pane exports
any port that could be used to distinguish between the selected tabs.




 

Thanks

Hilaire


Le 29/06/2017 à 14:59, Hilaire a écrit :
> but something is missing to get the listed method right depending on the
> category is instance or class side. I don't how to do it.

--
Dr. Geo
http://drgeo.eu


<panes.png>


Reply | Threaded
Open this post in threaded view
|

Re: Custom Glamour browser for Dr. Geo scripting

HilaireFernandes
Thanks Andrei for the tips! After adaptation, I have this script
browser. I will look to improve it a bit more with menu and syntax
colouring.

The wrapper part of your solution reads like Chinese to me. May be I am
miss using Glamour, and I will be happy to read about suggestions for
better use.

Hilaire


Le 01/07/2017 à 17:11, Andrei Chis a écrit :

> If I understood the issue correctly then the script below should
> address it.
> It starts from the solution Juraj proposed but wraps each
>  presentation in a wrapper.
> The script is not that obvious as this is not really a use case
> glamour supports out of the box.
> Also in glamour multiple presentations displayed within a composite
> share the selection. To avoid that they need to be wrapped. The
> simplest solution is to use a GLMWrapper.
>
--
Dr. Geo
http://drgeo.eu


Glamorous Browser.gif (29K) Download Attachment