[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Renaissance and EOInterface

From: Nicola Pero
Subject: Re: Renaissance and EOInterface
Date: Tue, 15 Jul 2003 10:56:30 +0100 (BST)

> Hi all,
> I am wondering how to use EOAssociations with Renaissance.
> The designated initializer of an EOAssociation is -initWithObject:
> with a display object, e.g. a text field.  Thus, an EOAssociation can't
> be included in the <objects> part of the markup file (with a syntax like
> <controlAssociation object="#myTextField"/>), because the implicit
> outlet connector semantic won't work (no method -setObject:).


> Maybe <controlAssociation object="myTextField"/> (without a hash) will
> work if I access the object attribute and convert the string contents
> to an object in -platformObjectInit myself, but I don't know if the
> existence of myTextField is guaranteed by Renaissance according to
> the order of the objects definition in the markup file.

Yes.  To me it looks like an association is really some sort of connector,
isn't it ?  It connects the GUI objects created by Renaissance with other
objects in your application.

You first create the objects in your interface, and, after you've created
all your GUI objects, you then set up the associations of the interface
objects with the display groups.  That is very much like outlets, where
you first create the objects, and then once all of them are created, you
set up the outlet connections of the interface objects with your
application's objects.

Also, the fact that you want to manually lookup the object reference is
very much similar to what an outlet wants to do - they too need to lookup
object by reference to connect them.

> This leaves creating the EOAssociation object for the <connectors> part.

This sounds right to me.

> Consider this example (assuming display groups #dg1 and #dg2 are
> already created somehow). Would something like this be feasible?
> -----
> <objects>
> ...
>       <textField id="tfName"/>
> ...
> </objects>
> <connectors>
>       <association instanceOf="controlAssociation" object="#tfName">
>               <connect displayGroup="#dg1" aspect="value" key="name"/>
>               <connect displayGroup="#dg2" aspect="enabled" key="boolVal"/>
>       </association>
> </connectors>
> -----

Yes - this seems nice to me.

> I didn't find places where the Renaissance XML parser reads nested tags
> (e.g. text fields inside windows).  So, I don't know yet if the framework
> is prepared to easily handle this.

Yes, it is prepared for nested tags.

The Renaissance XML parser will process tags as soon as the close tag is

For example,


What happens, is that when Renaissance reads </tagB>, it processes tagB
(creating the object representing it).  Then, when it reads </tagA>, it
processes tagA.  When processing tagA, it has already processed all
contents of tagA (because all tags inside tagA must have been closed
before tagA is closed).  So, when it initializes tagA, it passes to tagA
the array of objects representing the tags inside it.  That works very
well with building windows/views from components up to the entire window.

It is the responsibility of <tagA> to do something with the enclosed tags.

I suggest looking at the standard window/view/menu Renaissance tags for

In your case is slightly different/new because you are working in the
<connectors> section, but it should be very similar.

> Do you have some suggestions or comments? Should I try and proceed like
> in the example above?

It sounds nice to me.  I think the Renaissance connector code might need a
bit of revamp and extension to support your "advanced" connectors.  This
work is actually welcome as I've always wished to see advanced connectors
such as associations.

<some time later>

I've actually done a revamp and extension of the Renaissance connector
code which should hopefully help you with implementing associations.  
It's on CVS. :-)

You simply need to implement

@interface GSMarkupAssociationConnector : GSMarkupConnector

/* This is called to create the object when it is decoded from an XML
 * file.  Content are the nested tags if any.  Make sure to remove
 * the (optional) # at the start of attribute values which are id names 
 * of objects.
- (id) initWithAttributes: (NSDictionary *)attributes
                  content: (NSArray *)content;

/* These are used when encoding the object into an XML file.  You
 * need to return what you want to be encoded.  */
- (NSDictionary *) attributes;
- (NSArray *) content;
+ (NSString *) tagName;

/* This is called to establish the connection.  Inside this method,
 * you should use
 * [GSMarkupConnector getObjectForIdString: (NSString *)idString
 *                          usingNameTable: (NSDictionary *)nameTable]
 * to get the object corresponding to a certain id name.  Once you've
 * got all the objects you need, connect them :-) [presumably
 * creating the Associations, and connecting things around]
- (void) establishConnectionUsingNameTable: (NSDictionary *)nameTable;


Please have a look at GSMarkupConnector.h for more information, and check
the standard outlet connectors etc in Renaissance for simple examples.  
Let me know if something needs fixing / improving, if you have suggestions
etc. and finally once you've got something working!

Thanks for looking into this, I really appreciate it.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]