Moose browsers: Updating an object value from a text pane and from an emergent window

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

Moose browsers: Updating an object value from a text pane and from an emergent window

Offray
Hi,

I'm trying to restate my question to see if I have more luck with any
answer this time.

I'm making advances with an outliner like app for writing and now I can
add nodes move them and store them in the really nice STON format. But
because information on trees is not editable, I would like to try
another approach: To create an emergent window and put the node tree and
node tags on it, and the update the this values on the tree node.
Also, I would like to update some objects from the a Glamour text pane,
without any special button or action, just while I'm writing on them. If
this is not possible which is the message to select all text in a body
panel and to send it to a object?

I will be doing some further advances by my own and keep you posted (may
be with some more specific/better questions on how to get this behaviour
from Moose browsers).

Cheers,

Offray

Reply | Threaded
Open this post in threaded view
|

Re: Moose browsers: Updating an object value from a text pane and from an emergent window

Tudor Girba-2
Hi,

As I said before, right now, Glamour does not easily the behavior you want, but you can abuse an existing mechanism of capturing changes of a port through a transmission that transforms that value.

Here is an example:

text := ''.
GLMCompositePresentation new wrapper
with: [ :wrapper | 
wrapper show: [ :a |
a text ].
wrapper transmit fromOutsidePort: #text; toOutsidePort: #portIDoNotCareAbout; transformed: [ :textComingFromThePresentation | text := textComingFromThePresentation ] ];
openOn: text

In this example, we create a transmission that originates in the #text port that will be populated every time you modify something. This transmission sends the value to #portIDoNotCareAbout only to have access to the transformation block where you can do what you want with the textComingFromThePresentation.

To check the behavior:
- execute the code in a Playground, 
- type something in the text area that opens,
- inspect the text variable
==> you will see that it contains the latest contents from the text editor

We should promote this mechanism explicitly in Glamour, but in the meantime it is probably sufficient for your case.

Doru


On Wed, Sep 3, 2014 at 4:47 AM, Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
Hi,

I'm trying to restate my question to see if I have more luck with any answer this time.

I'm making advances with an outliner like app for writing and now I can add nodes move them and store them in the really nice STON format. But because information on trees is not editable, I would like to try another approach: To create an emergent window and put the node tree and node tags on it, and the update the this values on the tree node.
Also, I would like to update some objects from the a Glamour text pane, without any special button or action, just while I'm writing on them. If this is not possible which is the message to select all text in a body panel and to send it to a object?

I will be doing some further advances by my own and keep you posted (may be with some more specific/better questions on how to get this behaviour from Moose browsers).

Cheers,

Offray




--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: Moose browsers: Updating an object value from a text pane and from an emergent window

Offray
Hi Doru an community,

In almost a week from now I will write an small revision article about
this prototyping exercise on Moose/Glamour/Pharo, for structured
writing. My ideal would be to write it inside this prototype, but for
that I need to be able to edit and store the changes on the tree and its
node contents. Hopefully it won't take too much, even for a newbie like
me. Even if is not possible, and I need to go back to Leo Editor
(http://leoeditor.com/) for reporting and writing the article, this
exercise has been really valuable.

This are my issues so far:

Auto-updating objects from the browser is working but I'm having
problems to integrate this with my code. To follow better what is
happening just:

1. Follow the installation notes on:
http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install

2. Run this code:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| text mainTree |
mainTree := UbakyeNode new.
mainTree becomeDefaultTree.
text := (mainTree children at: 1) body.
GLMCompositePresentation new wrapper
with: [ :wrapper |
wrapper show: [ :a |
a text ].
wrapper transmit
        fromOutsidePort: #text;
        toOutsidePort: #portIDoNotCareAbout;
        transformed: [ :textComingFromThePresentation |
                text := textComingFromThePresentation ] ];
openOn: text.
(mainTree children at: 1) body: text
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

If I comment the last line, I can explore the Browser Tree and see how
#text updates automatically, but if I leave it uncommented I can explore
the mainTree and see that is not updating.

Also I tried to put the transmit parameters in the build browser
transmit parameter, just here:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
UbakyeBrowser>>buildBrowser

"(... snipped code)"
(browser transmit)
     to: #body;
     from: #tree;
     andShow: [ :a | self bodyOn: a].
"(...snipped code)"

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

replacing "to:", "from:" and "andShow:" for "fromOutsidePort:",
"toOutsidePort:" and "transformed:" as shown in your example, but then
the current selection in the tree got disconnected from the body pane.

I would mind to have a explicit button or keyboard shortcut to take what
is currently on a text pane and send it all to a particular node for
updating, if this is the quickest workaround. So, How can I made this?

Also, Doru showed to me a way to invoke inspector on the current
selected node. Suppose that I want to have an emergent window to edit
the node header and some tags on it. Is this possible?


Cheers and thanks in advance,

Offray

On 09/03/2014 04:27 AM, Tudor Girba wrote:

> Hi,
>
> As I said before, right now, Glamour does not easily the behavior you want, but
> you can abuse an existing mechanism of capturing changes of a port through a
> transmission that transforms that value.
>
> Here is an example:
>
> text := ''.
> GLMCompositePresentation new wrapper
> with: [ :wrapper |
> wrapper show: [ :a |
> a text ].
> wrapper transmit fromOutsidePort: #text; toOutsidePort: #portIDoNotCareAbout;
> transformed: [ :textComingFromThePresentation | text :=
> textComingFromThePresentation ] ];
> openOn: text
>
> In this example, we create a transmission that originates in the #text port that
> will be populated every time you modify something. This transmission sends the
> value to #portIDoNotCareAbout only to have access to the transformation block
> where you can do what you want with the textComingFromThePresentation.
>
> To check the behavior:
> - execute the code in a Playground,
> - type something in the text area that opens,
> - inspect the text variable
> ==> you will see that it contains the latest contents from the text editor
>
> We should promote this mechanism explicitly in Glamour, but in the meantime it
> is probably sufficient for your case.
>
> Doru
>
>
> On Wed, Sep 3, 2014 at 4:47 AM, Offray Vladimir Luna Cárdenas <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>      Hi,
>
>      I'm trying to restate my question to see if I have more luck with any answer
>      this time.
>
>      I'm making advances with an outliner like app for writing and now I can add
>      nodes move them and store them in the really nice STON format. But because
>      information on trees is not editable, I would like to try another approach:
>      To create an emergent window and put the node tree and node tags on it, and
>      the update the this values on the tree node.
>      Also, I would like to update some objects from the a Glamour text pane,
>      without any special button or action, just while I'm writing on them. If
>      this is not possible which is the message to select all text in a body panel
>      and to send it to a object?
>
>      I will be doing some further advances by my own and keep you posted (may be
>      with some more specific/better questions on how to get this behaviour from
>      Moose browsers).
>
>      Cheers,
>
>      Offray
>
>
>
>
> --
> www.tudorgirba.com <http://www.tudorgirba.com>
>
> "Every thing has its own flow"
>


Reply | Threaded
Open this post in threaded view
|

Re: Moose browsers: Updating an object value from a text pane and from an emergent window

Offray
Hi again,

I have opted for another option: Manually updating objects from text
panes. I have a method for showing the content of a node body:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
bodyOn: constructor
        "Shows the body of a selected node"
        (constructor text)
        title: 'Cuerpo | Body ';
                 format:[:eachNode |
           (eachNode body) isNil
               ifTrue: [ '' ]
               ifFalse: [ eachNode body]];
                 act: [:text |  text inspect ]
                 icon: GLMUIThemeExtraIcons glamorousRefresh
                 entitled: 'Save body'.
       
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

At this moment I have only "text inspect" as an action for the text
pane, but when I inspect it, I can see in the "Pane Ports" tab that any
text wrote there gets updated up to the moment of clicking in the
button. What I would like is to send the updated text as an argument for
the "body:" setter of the UbakyeNode object. I have seen in the PBE2
chapter about Glamorous that I can used ports to send values to the
outside, but still I don't get how.

Remember that you can upload the code by following the instructions here:

http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install

Any advice on this is appreciated.

Thanks in advance,

Offray

On 09/05/2014 10:58 PM, Offray Vladimir Luna Cárdenas wrote:

> Hi Doru an community,
>
> In almost a week from now I will write an small revision article about
> this prototyping exercise on Moose/Glamour/Pharo, for structured
> writing. My ideal would be to write it inside this prototype, but for
> that I need to be able to edit and store the changes on the tree and its
> node contents. Hopefully it won't take too much, even for a newbie like
> me. Even if is not possible, and I need to go back to Leo Editor
> (http://leoeditor.com/) for reporting and writing the article, this
> exercise has been really valuable.
>
> This are my issues so far:
>
> Auto-updating objects from the browser is working but I'm having
> problems to integrate this with my code. To follow better what is
> happening just:
>
> 1. Follow the installation notes on:
> http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install
>
> 2. Run this code:
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | text mainTree |
> mainTree := UbakyeNode new.
> mainTree becomeDefaultTree.
> text := (mainTree children at: 1) body.
> GLMCompositePresentation new wrapper
> with: [ :wrapper |
> wrapper show: [ :a |
> a text ].
> wrapper transmit
>      fromOutsidePort: #text;
>      toOutsidePort: #portIDoNotCareAbout;
>      transformed: [ :textComingFromThePresentation |
>          text := textComingFromThePresentation ] ];
> openOn: text.
> (mainTree children at: 1) body: text
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> If I comment the last line, I can explore the Browser Tree and see how
> #text updates automatically, but if I leave it uncommented I can explore
> the mainTree and see that is not updating.
>
> Also I tried to put the transmit parameters in the build browser
> transmit parameter, just here:
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> UbakyeBrowser>>buildBrowser
>
> "(... snipped code)"
> (browser transmit)
>      to: #body;
>      from: #tree;
>      andShow: [ :a | self bodyOn: a].
> "(...snipped code)"
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> replacing "to:", "from:" and "andShow:" for "fromOutsidePort:",
> "toOutsidePort:" and "transformed:" as shown in your example, but then
> the current selection in the tree got disconnected from the body pane.
>
> I would mind to have a explicit button or keyboard shortcut to take what
> is currently on a text pane and send it all to a particular node for
> updating, if this is the quickest workaround. So, How can I made this?
>
> Also, Doru showed to me a way to invoke inspector on the current
> selected node. Suppose that I want to have an emergent window to edit
> the node header and some tags on it. Is this possible?
>
>
> Cheers and thanks in advance,
>
> Offray
>
> On 09/03/2014 04:27 AM, Tudor Girba wrote:
>> Hi,
>>
>> As I said before, right now, Glamour does not easily the behavior you
>> want, but
>> you can abuse an existing mechanism of capturing changes of a port
>> through a
>> transmission that transforms that value.
>>
>> Here is an example:
>>
>> text := ''.
>> GLMCompositePresentation new wrapper
>> with: [ :wrapper |
>> wrapper show: [ :a |
>> a text ].
>> wrapper transmit fromOutsidePort: #text; toOutsidePort:
>> #portIDoNotCareAbout;
>> transformed: [ :textComingFromThePresentation | text :=
>> textComingFromThePresentation ] ];
>> openOn: text
>>
>> In this example, we create a transmission that originates in the #text
>> port that
>> will be populated every time you modify something. This transmission
>> sends the
>> value to #portIDoNotCareAbout only to have access to the
>> transformation block
>> where you can do what you want with the textComingFromThePresentation.
>>
>> To check the behavior:
>> - execute the code in a Playground,
>> - type something in the text area that opens,
>> - inspect the text variable
>> ==> you will see that it contains the latest contents from the text
>> editor
>>
>> We should promote this mechanism explicitly in Glamour, but in the
>> meantime it
>> is probably sufficient for your case.
>>
>> Doru
>>
>>
>> On Wed, Sep 3, 2014 at 4:47 AM, Offray Vladimir Luna Cárdenas
>> <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>      Hi,
>>
>>      I'm trying to restate my question to see if I have more luck with
>> any answer
>>      this time.
>>
>>      I'm making advances with an outliner like app for writing and now
>> I can add
>>      nodes move them and store them in the really nice STON format.
>> But because
>>      information on trees is not editable, I would like to try another
>> approach:
>>      To create an emergent window and put the node tree and node tags
>> on it, and
>>      the update the this values on the tree node.
>>      Also, I would like to update some objects from the a Glamour text
>> pane,
>>      without any special button or action, just while I'm writing on
>> them. If
>>      this is not possible which is the message to select all text in a
>> body panel
>>      and to send it to a object?
>>
>>      I will be doing some further advances by my own and keep you
>> posted (may be
>>      with some more specific/better questions on how to get this
>> behaviour from
>>      Moose browsers).
>>
>>      Cheers,
>>
>>      Offray
>>
>>
>>
>>
>> --
>> www.tudorgirba.com <http://www.tudorgirba.com>
>>
>> "Every thing has its own flow"
>>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Moose browsers: Updating an object value **explicitly** from a text pane

Offray
Hi,

I have tried a new strategy. I hope this time get some questions or some
pointers about what to do when a thread gets frozen, like this one.

For details on how to load the project on a vanilla Moose beta 5.0 image
follow the instructions at:

http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install

and then run "UbakyeBrowser open".


I have divided the code and now the browser it is composed with tree
main parts:


The first one builds the browser:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

UbakyeBrowser>>buildBrowser

"... Snipped code ..."

(browser transmit)
     to: #tree;
     andShow: [:a | self treeOn: a].

(browser transmit)
     to: #body;
     from: #tree;
     andShow: [ :a | self bodyOn: a].

"... Snipped code ..."

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

The second one builds the tree. The specific part which sends a constant
message for changing the body contents is this:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
UbakyeBrowser>> TreeOn: constructor

"... Snipped code ..."

act: [:treePresentation |
        (treePresentation selection isNotNil)
                ifTrue: [treePresentation selection body: 'Cambiado!'].
        treePresentation update]
icon: GLMUIThemeExtraIcons glamorousRefresh
entitled: 'Update body';

"... Snipped code ..."
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

And the third one just shows the body from the tree node like this:

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
UbakyeBrowser>> bodyOn: constructor

"Shows the body of a selected node"
(constructor text)
         title: 'Cuerpo | Body ';
        format:[:eachNode |
           (eachNode body) isNil
               ifTrue: [ '' ]
               ifFalse: [ eachNode body]].
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

So as you can see, the message I'm sending to update the node body,
explicitly by pressing a button, is a constant one (treePresentation
selection body: 'Cambiado!'), while I would like to send anything that
is contained in the text pane of the current node. I still don't get how
to do it with transmissions and I imagine that is related with something
like toOutsidePort or some message like that, but I still don't get it.

Any help will be appreciated or is anything I can do to move this
forward, let me know.

Cheers,

Offray



On 09/07/2014 09:56 PM, Offray Vladimir Luna Cárdenas wrote:

> Hi again,
>
> I have opted for another option: Manually updating objects from text
> panes. I have a method for showing the content of a node body:
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> bodyOn: constructor
>      "Shows the body of a selected node"
>      (constructor text)
>         title: 'Cuerpo | Body ';
>           format:[:eachNode |
>            (eachNode body) isNil
>                ifTrue: [ '' ]
>                ifFalse: [ eachNode body]];
>           act: [:text |  text inspect ]
>           icon: GLMUIThemeExtraIcons glamorousRefresh
>           entitled: 'Save body'.
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> At this moment I have only "text inspect" as an action for the text
> pane, but when I inspect it, I can see in the "Pane Ports" tab that any
> text wrote there gets updated up to the moment of clicking in the
> button. What I would like is to send the updated text as an argument for
> the "body:" setter of the UbakyeNode object. I have seen in the PBE2
> chapter about Glamorous that I can used ports to send values to the
> outside, but still I don't get how.
>
> Remember that you can upload the code by following the instructions here:
>
> http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install
>
> Any advice on this is appreciated.
>
> Thanks in advance,
>
> Offray
>
> On 09/05/2014 10:58 PM, Offray Vladimir Luna Cárdenas wrote:
>> Hi Doru an community,
>>
>> In almost a week from now I will write an small revision article about
>> this prototyping exercise on Moose/Glamour/Pharo, for structured
>> writing. My ideal would be to write it inside this prototype, but for
>> that I need to be able to edit and store the changes on the tree and its
>> node contents. Hopefully it won't take too much, even for a newbie like
>> me. Even if is not possible, and I need to go back to Leo Editor
>> (http://leoeditor.com/) for reporting and writing the article, this
>> exercise has been really valuable.
>>
>> This are my issues so far:
>>
>> Auto-updating objects from the browser is working but I'm having
>> problems to integrate this with my code. To follow better what is
>> happening just:
>>
>> 1. Follow the installation notes on:
>> http://wiki.hackbo.co/doku.php/herramientas:grafoscopio:en:install
>>
>> 2. Run this code:
>>
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>> | text mainTree |
>> mainTree := UbakyeNode new.
>> mainTree becomeDefaultTree.
>> text := (mainTree children at: 1) body.
>> GLMCompositePresentation new wrapper
>> with: [ :wrapper |
>> wrapper show: [ :a |
>> a text ].
>> wrapper transmit
>>      fromOutsidePort: #text;
>>      toOutsidePort: #portIDoNotCareAbout;
>>      transformed: [ :textComingFromThePresentation |
>>          text := textComingFromThePresentation ] ];
>> openOn: text.
>> (mainTree children at: 1) body: text
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>>
>> If I comment the last line, I can explore the Browser Tree and see how
>> #text updates automatically, but if I leave it uncommented I can explore
>> the mainTree and see that is not updating.
>>
>> Also I tried to put the transmit parameters in the build browser
>> transmit parameter, just here:
>>
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>> UbakyeBrowser>>buildBrowser
>>
>> "(... snipped code)"
>> (browser transmit)
>>      to: #body;
>>      from: #tree;
>>      andShow: [ :a | self bodyOn: a].
>> "(...snipped code)"
>>
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
>>
>> replacing "to:", "from:" and "andShow:" for "fromOutsidePort:",
>> "toOutsidePort:" and "transformed:" as shown in your example, but then
>> the current selection in the tree got disconnected from the body pane.
>>
>> I would mind to have a explicit button or keyboard shortcut to take what
>> is currently on a text pane and send it all to a particular node for
>> updating, if this is the quickest workaround. So, How can I made this?
>>
>> Also, Doru showed to me a way to invoke inspector on the current
>> selected node. Suppose that I want to have an emergent window to edit
>> the node header and some tags on it. Is this possible?
>>
>>
>> Cheers and thanks in advance,
>>
>> Offray
>>
>> On 09/03/2014 04:27 AM, Tudor Girba wrote:
>>> Hi,
>>>
>>> As I said before, right now, Glamour does not easily the behavior you
>>> want, but
>>> you can abuse an existing mechanism of capturing changes of a port
>>> through a
>>> transmission that transforms that value.
>>>
>>> Here is an example:
>>>
>>> text := ''.
>>> GLMCompositePresentation new wrapper
>>> with: [ :wrapper |
>>> wrapper show: [ :a |
>>> a text ].
>>> wrapper transmit fromOutsidePort: #text; toOutsidePort:
>>> #portIDoNotCareAbout;
>>> transformed: [ :textComingFromThePresentation | text :=
>>> textComingFromThePresentation ] ];
>>> openOn: text
>>>
>>> In this example, we create a transmission that originates in the #text
>>> port that
>>> will be populated every time you modify something. This transmission
>>> sends the
>>> value to #portIDoNotCareAbout only to have access to the
>>> transformation block
>>> where you can do what you want with the textComingFromThePresentation.
>>>
>>> To check the behavior:
>>> - execute the code in a Playground,
>>> - type something in the text area that opens,
>>> - inspect the text variable
>>> ==> you will see that it contains the latest contents from the text
>>> editor
>>>
>>> We should promote this mechanism explicitly in Glamour, but in the
>>> meantime it
>>> is probably sufficient for your case.
>>>
>>> Doru
>>>
>>>
>>> On Wed, Sep 3, 2014 at 4:47 AM, Offray Vladimir Luna Cárdenas
>>> <[hidden email]
>>> <mailto:[hidden email]>> wrote:
>>>
>>>      Hi,
>>>
>>>      I'm trying to restate my question to see if I have more luck with
>>> any answer
>>>      this time.
>>>
>>>      I'm making advances with an outliner like app for writing and now
>>> I can add
>>>      nodes move them and store them in the really nice STON format.
>>> But because
>>>      information on trees is not editable, I would like to try another
>>> approach:
>>>      To create an emergent window and put the node tree and node tags
>>> on it, and
>>>      the update the this values on the tree node.
>>>      Also, I would like to update some objects from the a Glamour text
>>> pane,
>>>      without any special button or action, just while I'm writing on
>>> them. If
>>>      this is not possible which is the message to select all text in a
>>> body panel
>>>      and to send it to a object?
>>>
>>>      I will be doing some further advances by my own and keep you
>>> posted (may be
>>>      with some more specific/better questions on how to get this
>>> behaviour from
>>>      Moose browsers).
>>>
>>>      Cheers,
>>>
>>>      Offray
>>>
>>>
>>>
>>>
>>> --
>>> www.tudorgirba.com <http://www.tudorgirba.com>
>>>
>>> "Every thing has its own flow"
>>>
>>
>>
>>
>
>
>