Customizing the display of a relation

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

Customizing the display of a relation

Rogier Schaaf
I have a default Magritte edit form for a model that maintains a relation to a single instance of GeoLocation, a model object with two instance variables: longitude and latitude. The relation is defined as a MAToOneRelationDescription.

On the form, the instance of GeoLocation is displayed as the integer of the longitude attribute, however I want a representation like:

lon: 12.67, lat: 34.09

I looked at MAToOneRelationDescription and its superclass MAElementDescription implements a #display: method which either accepts a symbol or a block to customize the display. I've implemented a #printString method with GeoLocation and passed that to the relation description as:

display: #printString

and

display: [ :anObject | ^ anObject printString ]

But as far as I can tell both the symbol and the block get ignored when displaying the GeoLocation instance in the Magritte form.

What should I change to get the required display?

Thanks,

Roger

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the display of a relation

JupiterJones
Hi Roger,

I seem to remember the same issue with display - I can’t remember if it’s called at all. :)

Regardless, I opted to set a reference description along the lines of:

locationsDescription
<magritteDescription>
 | template |
 template := GeoLocation new.
 ^ MAToManyRelationDescription new
   accessor: #’geoLocations';
   classes: { GeoLocation };
   label: ‘Locations';
   reference: template descriptionDisplayString asContainer;
   yourself

…and the descriptionDisplayString would be something like:

descriptionDisplayString
 "<magritteDescription> note the comment to stop this becoming part of the default description"
 ^ MAStringDescription new
   accessor: #’printString';
   label: ‘Location';
   priority: 100;
   beReadonly;
   yourself

Let me know how it goes.

Cheers,

J

> On 30 May 2015, at 12:09 am, Rogier Schaaf <[hidden email]> wrote:
>
> I have a default Magritte edit form for a model that maintains a relation to a single instance of GeoLocation, a model object with two instance variables: longitude and latitude. The relation is defined as a MAToOneRelationDescription.
>
> On the form, the instance of GeoLocation is displayed as the integer of the longitude attribute, however I want a representation like:
>
> lon: 12.67, lat: 34.09
>
> I looked at MAToOneRelationDescription and its superclass MAElementDescription implements a #display: method which either accepts a symbol or a block to customize the display. I've implemented a #printString method with GeoLocation and passed that to the relation description as:
>
> display: #printString
>
> and
>
> display: [ :anObject | ^ anObject printString ]
>
> But as far as I can tell both the symbol and the block get ignored when displaying the GeoLocation instance in the Magritte form.
>
> What should I change to get the required display?
>
> Thanks,
>
> Roger
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the display of a relation

Rogier Schaaf
Hi Jupiter,

Thanks for that. It solved the issue. Are you by chance aware of a decent sample application that is based Magritte that I can load in a Pharo image? Or maybe even one based on TWBS (Twitter Bootstrap) for Magritte?

Cheers,

Roger

On 31 May 2015 at 08:52, Jupiter Jones <[hidden email]> wrote:
Hi Roger,

I seem to remember the same issue with display - I can’t remember if it’s called at all. :)

Regardless, I opted to set a reference description along the lines of:

locationsDescription
<magritteDescription>
 | template |
 template := GeoLocation new.
 ^ MAToManyRelationDescription new
   accessor: #’geoLocations';
   classes: { GeoLocation };
   label: ‘Locations';
   reference: template descriptionDisplayString asContainer;
   yourself

…and the descriptionDisplayString would be something like:

descriptionDisplayString
 "<magritteDescription> note the comment to stop this becoming part of the default description"
 ^ MAStringDescription new
   accessor: #’printString';
   label: ‘Location';
   priority: 100;
   beReadonly;
   yourself

Let me know how it goes.

Cheers,

J

> On 30 May 2015, at 12:09 am, Rogier Schaaf <[hidden email]> wrote:
>
> I have a default Magritte edit form for a model that maintains a relation to a single instance of GeoLocation, a model object with two instance variables: longitude and latitude. The relation is defined as a MAToOneRelationDescription.
>
> On the form, the instance of GeoLocation is displayed as the integer of the longitude attribute, however I want a representation like:
>
> lon: 12.67, lat: 34.09
>
> I looked at MAToOneRelationDescription and its superclass MAElementDescription implements a #display: method which either accepts a symbol or a block to customize the display. I've implemented a #printString method with GeoLocation and passed that to the relation description as:
>
> display: #printString
>
> and
>
> display: [ :anObject | ^ anObject printString ]
>
> But as far as I can tell both the symbol and the block get ignored when displaying the GeoLocation instance in the Magritte form.
>
> What should I change to get the required display?
>
> Thanks,
>
> Roger
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
ksi
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the display of a relation

ksi
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the display of a relation

JupiterJones
In reply to this post by Rogier Schaaf
Hi Roger,


It’s like jumping in the deep end, but I learnt a lot from it.

Cheers,

J

On 2 Jun 2015, at 12:13 am, Rogier Schaaf <[hidden email]> wrote:

Hi Jupiter,

Thanks for that. It solved the issue. Are you by chance aware of a decent sample application that is based Magritte that I can load in a Pharo image? Or maybe even one based on TWBS (Twitter Bootstrap) for Magritte?

Cheers,

Roger

On 31 May 2015 at 08:52, Jupiter Jones <[hidden email]> wrote:
Hi Roger,

I seem to remember the same issue with display - I can’t remember if it’s called at all. :)

Regardless, I opted to set a reference description along the lines of:

locationsDescription
<magritteDescription>
 | template |
 template := GeoLocation new.
 ^ MAToManyRelationDescription new
   accessor: #’geoLocations';
   classes: { GeoLocation };
   label: ‘Locations';
   reference: template descriptionDisplayString asContainer;
   yourself

…and the descriptionDisplayString would be something like:

descriptionDisplayString
 "<magritteDescription> note the comment to stop this becoming part of the default description"
 ^ MAStringDescription new
   accessor: #’printString';
   label: ‘Location';
   priority: 100;
   beReadonly;
   yourself

Let me know how it goes.

Cheers,

J

> On 30 May 2015, at 12:09 am, Rogier Schaaf <[hidden email]> wrote:
>
> I have a default Magritte edit form for a model that maintains a relation to a single instance of GeoLocation, a model object with two instance variables: longitude and latitude. The relation is defined as a MAToOneRelationDescription.
>
> On the form, the instance of GeoLocation is displayed as the integer of the longitude attribute, however I want a representation like:
>
> lon: 12.67, lat: 34.09
>
> I looked at MAToOneRelationDescription and its superclass MAElementDescription implements a #display: method which either accepts a symbol or a block to customize the display. I've implemented a #printString method with GeoLocation and passed that to the relation description as:
>
> display: #printString
>
> and
>
> display: [ :anObject | ^ anObject printString ]
>
> But as far as I can tell both the symbol and the block get ignored when displaying the GeoLocation instance in the Magritte form.
>
> What should I change to get the required display?
>
> Thanks,
>
> Roger


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Customizing the display of a relation

Rogier Schaaf
Hi Jupiter,

Great link, thanks very much!

Cheers,
Roger

On 1 June 2015 at 22:48, Jupiter Jones <[hidden email]> wrote:
Hi Roger,


It’s like jumping in the deep end, but I learnt a lot from it.

Cheers,

J

On 2 Jun 2015, at 12:13 am, Rogier Schaaf <[hidden email]> wrote:

Hi Jupiter,

Thanks for that. It solved the issue. Are you by chance aware of a decent sample application that is based Magritte that I can load in a Pharo image? Or maybe even one based on TWBS (Twitter Bootstrap) for Magritte?

Cheers,

Roger

On 31 May 2015 at 08:52, Jupiter Jones <[hidden email]> wrote:
Hi Roger,

I seem to remember the same issue with display - I can’t remember if it’s called at all. :)

Regardless, I opted to set a reference description along the lines of:

locationsDescription
<magritteDescription>
 | template |
 template := GeoLocation new.
 ^ MAToManyRelationDescription new
   accessor: #’geoLocations';
   classes: { GeoLocation };
   label: ‘Locations';
   reference: template descriptionDisplayString asContainer;
   yourself

…and the descriptionDisplayString would be something like:

descriptionDisplayString
 "<magritteDescription> note the comment to stop this becoming part of the default description"
 ^ MAStringDescription new
   accessor: #’printString';
   label: ‘Location';
   priority: 100;
   beReadonly;
   yourself

Let me know how it goes.

Cheers,

J

> On 30 May 2015, at 12:09 am, Rogier Schaaf <[hidden email]> wrote:
>
> I have a default Magritte edit form for a model that maintains a relation to a single instance of GeoLocation, a model object with two instance variables: longitude and latitude. The relation is defined as a MAToOneRelationDescription.
>
> On the form, the instance of GeoLocation is displayed as the integer of the longitude attribute, however I want a representation like:
>
> lon: 12.67, lat: 34.09
>
> I looked at MAToOneRelationDescription and its superclass MAElementDescription implements a #display: method which either accepts a symbol or a block to customize the display. I've implemented a #printString method with GeoLocation and passed that to the relation description as:
>
> display: #printString
>
> and
>
> display: [ :anObject | ^ anObject printString ]
>
> But as far as I can tell both the symbol and the block get ignored when displaying the GeoLocation instance in the Magritte form.
>
> What should I change to get the required display?
>
> Thanks,
>
> Roger


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki