closing/deleting a morph and dependents

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

closing/deleting a morph and dependents

Dietmar Schielke

Hi Squeakers,

i made a simple morph with submorphs. the submorphs are views for some domain objects and are dependents of them ( domainobj addDependent: mysubmorph ).
Every thing works fine :-)
but i can't figure out, how to remove my submorphs from the dependents list of my domain object, when I close/delete my morphic gui.
It seems Morph delete does not call delete recursively on its submorphs. Is there an other way submorphs get informed when they are removed from the screen?

Thanks in advance,

Dietmar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: closing/deleting a morph and dependents

Edgar J. De Cleene



El 6/5/07 4:24 AM, "Dietmar Schielke" <[hidden email]>
escribió:

>
> Hi Squeakers,
>
> i made a simple morph with submorphs. the submorphs are views for some domain
> objects and are dependents of them ( domainobj addDependent: mysubmorph ).
> Every thing works fine :-)
> but i can't figure out, how to remove my submorphs from the dependents list of
> my domain object, when I close/delete my morphic gui.
> It seems Morph delete does not call delete recursively on its submorphs. Is
> there an other way submorphs get informed when they are removed from the
> screen?
>
> Thanks in advance,
>
> Dietmar


Could send sample ?
Morph could be viewed as "containers" of all submorphs inside .
As example any Tools is a SystemWindow and a model for it.
Select a Browser as example and you could see have many submorphs.
Deleting the window , delete all submorphs inside.

Or I misunderstanding you ?

Edgar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: closing/deleting a morph and dependents

Dietmar Schielke

Hi Edgar,

thanks for your answer :-)
I will have to describe it better.

Yes my morph and its submorphs disappear correctly when I close/delete it.

My problem is, that the submorphs need to do some clean up (unregister as dependents from the domain objects)  when they disapear from the world . I tried to overwrite delete in my submorphs, but delete was not called on my submorphs when i closed/deleted my GUI.

Here is a short sketch of my classes:

I have a class Device (with attributes name, ip-Adress, port) which holds subdevices (objects of class Subdevice with attributes like name, description, state..)

To view and edit Devices with their subdevices i made a DeviceMorph (for viewing/editing the "primitive" attributes of Device) and a SubdeviceMorph (for the SubDevices). Devicemorphs hold Subdevicemorphs as submorphs. Subdevicemorphs register themself as dependent on an Subdevice object so they get infomed when the  Subdevice changes it's state (just the squeak standard change notification mechanics). This works fine. I can open several DeviceMorphs for the same Device and a change on the device or its subdevices via one of the openDevice Morphs ist instantly displayed on all open DeviceMorphs for that device.

When i close one of the DeviceMorphs observing my Device i need to unregister its SubDeviceMorphs from the SubDivices they have observed, because they are no longer visible and do not need the change notifications of their SubDevice anymore and because the reference from my SubDevice to my (now unvisible) SubDeviceMorph prevents the SubDeviceMorph from being garbage collected.

Btw. I copied this design from the morphic counter example on http://wiki.squeak.org/squeak/795. The difference between the counter example an my problem is, that my domain objects live more independent of the GUI.

I have seen that morphs can have a model, but i have no idea how to use it.

Thanks again,

Dietmar

Edgar schrieb:
>El 6/5/07 4:24 AM, "Dietmar Schielke" <[hidden email]>
>escribió:
>
>>
>> Hi Squeakers,
>>
>> i made a simple morph with submorphs. the submorphs are views for some domain
>> objects and are dependents of them ( domainobj addDependent: mysubmorph ).
>> Every thing works fine :-)
>> but i can't figure out, how to remove my submorphs from the dependents list of
>> my domain object, when I close/delete my morphic gui.
>> It seems Morph delete does not call delete recursively on its submorphs. Is
>> there an other way submorphs get informed when they are removed from the
>> screen?
>>
>> Thanks in advance,
>>
>> Dietmar
>
>Could send sample ?
>Morph could be viewed as "containers" of all submorphs inside .
>As example any Tools is a SystemWindow and a model for it.
>Select a Browser as example and you could see have many submorphs.
>Deleting the window , delete all submorphs inside.
>
>Or I misunderstanding you ?
>
>Edgar

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: closing/deleting a morph and dependents

Edgar J. De Cleene



El 6/5/07 7:56 AM, "Dietmar Schielke" <[hidden email]>
escribió:

> Hi Edgar,
>
> thanks for your answer :-)
> I will have to describe it better.
>
> Yes my morph and its submorphs disappear correctly when I close/delete it.
>
> My problem is, that the submorphs need to do some clean up (unregister as
> dependents from the domain objects)  when they disapear from the world . I
> tried to overwrite delete in my submorphs, but delete was not called on my
> submorphs when i closed/deleted my GUI.
>
> Here is a short sketch of my classes:
>
> I have a class Device (with attributes name, ip-Adress, port) which holds
> subdevices (objects of class Subdevice with attributes like name, description,
> state..)
>
> To view and edit Devices with their subdevices i made a DeviceMorph (for
> viewing/editing the "primitive" attributes of Device) and a SubdeviceMorph
> (for the SubDevices). Devicemorphs hold Subdevicemorphs as submorphs.
> Subdevicemorphs register themself as dependent on an Subdevice object so they
> get infomed when the  Subdevice changes it's state (just the squeak standard
> change notification mechanics). This works fine. I can open several
> DeviceMorphs for the same Device and a change on the device or its subdevices
> via one of the openDevice Morphs ist instantly displayed on all open
> DeviceMorphs for that device.
>
> When i close one of the DeviceMorphs observing my Device i need to unregister
> its SubDeviceMorphs from the SubDivices they have observed, because they are
> no longer visible and do not need the change notifications of their SubDevice
> anymore and because the reference from my SubDevice to my (now unvisible)
> SubDeviceMorph prevents the SubDeviceMorph from being garbage collected.
>
> Btw. I copied this design from the morphic counter example on
> http://wiki.squeak.org/squeak/795. The difference between the counter example
> an my problem is, that my domain objects live more independent of the GUI.
>
> I have seen that morphs can have a model, but i have no idea how to use it.
>
> Thanks again,
>
> Dietmar

I understand better now.
It's really a good start point for doing a tutorial.
I don't have time as 3.10 monopolize all I get, try to find some student for
do it.

In the time, I have my very old tutorial
http://ar.geocities.com/edgardec2001/LogicCircus1.html
see pict of finished project at:
http://wiki.squeak.org/squeak/5991

Is my bad use of  Fabrik Dan idea  for connecting and passing actions
between morphic objects.

If think this could be useful , I have ready to load in any Squeak , could
send or put somewhere.

Edgar



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Antwort: Re: closing/deleting a morph and dependents

Dietmar Schielke

Thank for your links. I'll try to dig further into it.

A first look into SwitchMorph raises a first question in me:

When you call addDependent: should'nt be there a corresponding removeDependent: in the code?

Maybe connection: should first call removeDependent: for the old connection before setting a new connection?
Further, then I delete a SwitchMorph maybe  it should also disconnect from its's connections?

Like

connection: anObject
"Set anObject to be the connection among two or more Switches. Make the
receiver a dependent of the argument, anObject."

connection ifNotNil: [ connection removeDependent: self ].    " THIS IS NEW"
connection _ anObject.
connection addDependent: self


Dietmar



"Edgar J. De Cleene" <[hidden email]>
Gesendet von: [hidden email]

05.06.2007 13:37

Bitte antworten an
"A friendly place to get answers to even the most basic questions        about Squeak." <[hidden email]>

An
"A friendly place to get answers to even the most basic questions about        Squeak." <[hidden email]>
Kopie
Thema
Re: Antwort: Re: [Newbies] closing/deleting a morph and dependents








El 6/5/07 7:56 AM, "Dietmar Schielke" <[hidden email]>
escribió:

> Hi Edgar,
>
> thanks for your answer :-)
> I will have to describe it better.
>
> Yes my morph and its submorphs disappear correctly when I close/delete it.
>
> My problem is, that the submorphs need to do some clean up (unregister as
> dependents from the domain objects)  when they disapear from the world . I
> tried to overwrite delete in my submorphs, but delete was not called on my
> submorphs when i closed/deleted my GUI.
>
> Here is a short sketch of my classes:
>
> I have a class Device (with attributes name, ip-Adress, port) which holds
> subdevices (objects of class Subdevice with attributes like name, description,
> state..)
>
> To view and edit Devices with their subdevices i made a DeviceMorph (for
> viewing/editing the "primitive" attributes of Device) and a SubdeviceMorph
> (for the SubDevices). Devicemorphs hold Subdevicemorphs as submorphs.
> Subdevicemorphs register themself as dependent on an Subdevice object so they
> get infomed when the  Subdevice changes it's state (just the squeak standard
> change notification mechanics). This works fine. I can open several
> DeviceMorphs for the same Device and a change on the device or its subdevices
> via one of the openDevice Morphs ist instantly displayed on all open
> DeviceMorphs for that device.
>
> When i close one of the DeviceMorphs observing my Device i need to unregister
> its SubDeviceMorphs from the SubDivices they have observed, because they are
> no longer visible and do not need the change notifications of their SubDevice
> anymore and because the reference from my SubDevice to my (now unvisible)
> SubDeviceMorph prevents the SubDeviceMorph from being garbage collected.
>
> Btw. I copied this design from the morphic counter example on
> http://wiki.squeak.org/squeak/795. The difference between the counter example
> an my problem is, that my domain objects live more independent of the GUI.
>
> I have seen that morphs can have a model, but i have no idea how to use it.
>
> Thanks again,
>
> Dietmar

I understand better now.
It's really a good start point for doing a tutorial.
I don't have time as 3.10 monopolize all I get, try to find some student for
do it.

In the time, I have my very old tutorial
http://ar.geocities.com/edgardec2001/LogicCircus1.html
see pict of finished project at:
http://wiki.squeak.org/squeak/5991

Is my bad use of  Fabrik Dan idea  for connecting and passing actions
between morphic objects.

If think this could be useful , I have ready to load in any Squeak , could
send or put somewhere.

Edgar



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Re: closing/deleting a morph and dependents

Edgar J. De Cleene



El 6/5/07 9:20 AM, "Dietmar Schielke" <[hidden email]>
escribió:

>
> Thank for your links. I'll try to dig further into it.
>
> A first look into SwitchMorph raises a first question in me:
>
> When you call addDependent: should'nt be there a corresponding
> removeDependent: in the code?
>
> Maybe connection: should first call removeDependent: for the old connection
> before setting a new connection?
> Further, then I delete a SwitchMorph maybe  it should also disconnect from
> its's connections?
At the time I have
descablear
    submorphs
        do: [:each |
            each isConnectionSet
                ifTrue: [each notifyRemoveMe].
            each color: Color yellow]

And I raise this with yellow click on the choosed Morph.

here how to have your own colored menu !!!

addMenuItemsTo: aMenu hand: aHandMorph
    | menu |
    menu := MenuMorph new.
    menu color: Color blue.
    menu
        color: (menu color alpha: 0.3).
    menu
        add: 'descablear '
        target: self
        action: #descablear.
    menu items
        do: [:i | i color: Color yellow;
               
                font: (StrikeFont
                        familyName: 'Comic Bold'
                        size: 18
                        emphasized: 1)].
    menu invokeModal

Maybe today I do all different ....

As said, I have many different versions for you cook your own ideas.

Edgar



_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: Antwort: Re: Antwort: Re: closing/deleting a morph and dependents

Dietmar Schielke

Hi Edgar,

tx for the code snipets.

I figured something out by my self :-)

1. When a Morph is removed from the world
outOfWorld: aWorld
is called on the morph und recursive an all its submorphs.
So I can simply override outOfWorld: in my SubDeviceMorphs.
Im not shur if this is the correct way, but it works.

2. The dependents of an object are held in an weak array so the cleanup i want is not realy neccesary.

Dietmar

[hidden email] schrieb am 05.06.2007 14:45:54:

>
>
>
> El 6/5/07 9:20 AM, "Dietmar Schielke" <[hidden email]>
> escribió:
>
> >
> > Thank for your links. I'll try to dig further into it.
> >
> > A first look into SwitchMorph raises a first question in me:
> >
> > When you call addDependent: should'nt be there a corresponding
> > removeDependent: in the code?
> >
> > Maybe connection: should first call removeDependent: for the old connection
> > before setting a new connection?
> > Further, then I delete a SwitchMorph maybe  it should also disconnect from
> > its's connections?
> At the time I have
> descablear
>     submorphs
>         do: [:each |
>             each isConnectionSet
>                 ifTrue: [each notifyRemoveMe].
>             each color: Color yellow]
>
> And I raise this with yellow click on the choosed Morph.
>
> here how to have your own colored menu !!!
>
> addMenuItemsTo: aMenu hand: aHandMorph
>     | menu |
>     menu := MenuMorph new.
>     menu color: Color blue.
>     menu
>         color: (menu color alpha: 0.3).
>     menu
>         add: 'descablear '
>         target: self
>         action: #descablear.
>     menu items
>         do: [:i | i color: Color yellow;
>                
>                 font: (StrikeFont
>                         familyName: 'Comic Bold'
>                         size: 18
>                         emphasized: 1)].
>     menu invokeModal
>
> Maybe today I do all different ....
>
> As said, I have many different versions for you cook your own ideas.
>
> Edgar
>
>
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Antwort: Re: Antwort: Re: Antwort: Re: closing/deleting a morph and dependents

Edgar J. De Cleene



El 6/5/07 11:33 AM, "Dietmar Schielke" <[hidden email]>
escribió:

> I figured something out by my self :-)

Very good !
I very sure could do nice things now you beginning the Squeak gestalt

Edgar


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners