Hi Marcelo,
Something just struck me. What happens if you use GWT.getTypeName(binded)
instead of  label.setText(binded.getClass().getName())?

Hope that helps,
-Sumit Chandel

On Thu, Mar 26, 2009 at 6:42 PM, Marcelo Emanoel B. Diniz <
[email protected]> wrote:

>
> Hi Sumit here are the generator rule and the generator class:
>
> rule:
>        <generate-with
> class="br.com.gwt.symbiosis.rebind.generator.BoundModelGenerator">
>                <when-type-assignable
> class="br.com.gwt.symbiosis.client.bind.BindingModel" />
>        </generate-with>
>
>        <generate-with
> class="br.com.gwt.symbiosis.rebind.generator.BoundViewGenerator">
>                <when-type-assignable
> class="br.com.gwt.symbiosis.client.bind.BindingView" />
>        </generate-with>
>
> View generator class:
> public class BoundViewGenerator extends Generator {
>
>        private static final String MODEL_INTERFACE =
> "br.com.gwt.symbiosis.client.bind.BindingModel";
>        private static final String SOURCES_PROPERTY_CHANGES =
> "br.com.gwt.symbiosis.client.event.SourcesPropertyChanges";
>
>        public String generate(TreeLogger logger, GeneratorContext context,
>                        String typeName) throws UnableToCompleteException {
>
>                TypeOracle oracle = context.getTypeOracle();
>                JClassType type = oracle.findType(typeName);
>                JClassType modelType = oracle.findType(MODEL_INTERFACE);
>
>                BoundModelClass modelClass = new BoundModelClass(type);
>                modelClass.setModelType(modelType);
>                BindTypeManager bindManager = BindTypeManager.getInstance();
>
>                for(JField field : type.getFields()){
>                        JClassType fieldClass =
> field.getType().isClassOrInterface();
>
>                        for(String className :
> bindManager.getAvailableTypes()){
>                                JClassType bindClass =
> oracle.findType(className);
>                                if(fieldClass.isAssignableTo(bindClass)){
>                                        for(ListenerTemplate template :
> bindManager.getTemplatesForType
> (className)){
>
>  modelClass.associateFieldListener(field, template);
>                                        }
>                                }
>                        }
>                }
>
>                String packageName = modelClass.getPackageName();
>                String newLine = System.getProperty("line.separator");
>
>                String finalViewClassName =
> "Bound_"+modelClass.getClassName()
> +"_View";
>                PrintWriter printer = context.tryCreate(logger, packageName,
> finalViewClassName);
>
>                if (printer == null){
>                        System.out.println("printer == null");
>                        return null;
>                }
>
>                ClassSourceFileComposerFactory composer = null;
>                composer = new ClassSourceFileComposerFactory(packageName,
> finalViewClassName);
>                composer.setSuperclass(type.getSimpleSourceName());
>                composer.addImport(SOURCES_PROPERTY_CHANGES);
>
>                SourceWriter sourceWriter =
> composer.createSourceWriter(context,
> printer);
>
>                Bound_ViewTemplate template =
> Bound_ViewTemplate.create(newLine);
>                System.out.println(template.generate(modelClass));
>                sourceWriter.println(template.generate(modelClass));
>
>
>                context.commit(logger, printer);
>
>                return packageName + "." + finalViewClassName;
>        }
> }
>
> Model generator class:
>
> public class BoundModelGenerator extends Generator {
>
>        private static final String SOURCES_PROPERTY_CHANGES =
> "br.com.gwt.symbiosis.client.event.SourcesPropertyChanges";
>        private static final String PROPERTY_CHANGE_SUPPORT =
> "br.com.gwt.symbiosis.client.event.PropertyChangeSupport";
>        private static final String PROPERTY_CHANGE_LISTENER =
> "br.com.gwt.symbiosis.client.event.PropertyChangeListener";
>        private static final String BOUND_PREFIX = "Bound_";
>
>        public String generate(TreeLogger logger, GeneratorContext context,
>                        String typeName) throws UnableToCompleteException {
>
>                TypeOracle oracle = context.getTypeOracle();
>                JClassType type = oracle.findType(typeName);
>
>                BoundModelClass modelClass = new BoundModelClass(type);
>                String generatedClass = new Bound_ModelTemplate().generate
> (modelClass);
>                System.out.println(generatedClass);
>
>        String packageName = modelClass.getPackageName();
>                String generatedClassName =
> BOUND_PREFIX+modelClass.getClassName();
>
>                PrintWriter printer = context.tryCreate(logger, packageName,
> generatedClassName);
>
>        if (printer == null){
>                        return null;
>        }
>
>        ClassSourceFileComposerFactory composer = null;
>        composer = new ClassSourceFileComposerFactory(packageName,
> generatedClassName);
>
>        composer.setSuperclass(type.getSimpleSourceName());
>        composer.addImplementedInterface(SOURCES_PROPERTY_CHANGES);
>        composer.addImport(PROPERTY_CHANGE_LISTENER);
>        composer.addImport(PROPERTY_CHANGE_SUPPORT);
>        composer.addImport(SOURCES_PROPERTY_CHANGES);
>
>        SourceWriter sourceWriter = composer.createSourceWriter
> (context, printer);
>        sourceWriter.println(generatedClass);
>        context.commit(logger, printer);
>                return packageName + "." + generatedClassName;
>        }
> }
>
> I'll put the code at the project's site: http://code.google.com/p/glue4gwt
>
> The strange thing is that when the compile button is pressed... the
> generator is called... but the code generated isn't used...
> anyway thanks for the help :)
>
> On Mar 24, 12:23 pm, Sumit Chandel <[email protected]> wrote:
> > Hi Marcelo,
> > It might help to post up the generator rule and especially the generate()
> > implementation that is being used to generate the FormView generated
> type.
> > My thought is that whatever is going on in there is depending on rules
> that
> > might not hold true in web mode.
> >
> > Cheers,
> > -Sumit Chandel
> >
> > On Thu, Mar 19, 2009 at 2:46 PM, Marcelo Emanoel B. Diniz <
> >
> > [email protected]> wrote:
> >
> > > this is my entry point
> >
> > > package br.com.gwt.symbiosis.client;
> >
> > > import br.com.gwt.symbiosis.client.mock.FormView;
> >
> > > import com.google.gwt.core.client.EntryPoint;
> > > import com.google.gwt.core.client.GWT;
> > > import com.google.gwt.user.client.ui.Label;
> > > import com.google.gwt.user.client.ui.RootPanel;
> >
> > > public class Symbiosis implements EntryPoint {
> >
> > >        public void onModuleLoad() {
> > >                FormView binded = GWT.create(FormView.class);
> > >                Label label = new Label();
> > >                label.setText(binded.getClass().getName());
> > >                RootPanel.get().add(binded);
> > >                RootPanel.get().add(label);
> > >        }
> > > }
> >
> > > on hosted mode the label text is
> > > "br.com.gwt.symbiosis.client.mock.Bound_FormView_View" wich is in fact
> > > what is expected to be...
> > > but at web mode the label text is
> > > ''br.com.gwt.symbiosis.client.mock.FormView" which in turn is not what
> > > I need... and doesn't work as expected either... :(
> >
> > > by the way... there's no complain on the console....
> >
> > > On Mar 19, 3:53 pm, Marcelo Emanoel <[email protected]> wrote:
> > > > Hi guys I have a problem with generators... I've manage to do 2
> > > > generators and they work fine on hosted mode.... however they don't
> > > > work when I compile code to web mode :( What I'm trying to acomplish
> > > > is to build an API for binding... An important thing is that my
> > > > generators work on hosted mode and they are called when the code
> start
> > > > is compiled....
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to