Vaadin Designer Suggestion...

So I’m finding it hard to keep my code out of the generated java class out of the designer. A couple of times now I had to go back and create a subclass and then move my code.

Couldn’t the designer take the name I give it, i.e. ImportExportOptions and create two java classes, AbstractImportExportOptions and ImportExportOptions? Make the abstract one abstract and include the generated code there, then leave the ImportExportOptions for me to play in?

I mean, if I’m really supposed to keep my code away from the generated code, creating the two different classes would go a long way towards promoting that…

Hi,

Just to be clear, when you say you’re having a hard time, do you mean you’re “accidentally” putting code in the class, or is there som technical reason why you need code in the generated class?

We investigated options for making the class hard to edit, e.g by marking it as a ‘derived resource’ in Eclipse, but everything we came up with had undesired side-effects. Instead we decided to go with a big warning comment and overwriting everything each time so there is no question what can be edited - and also go with a minimalistic solution as first, expanding once we get good feedback - so here we are :slight_smile:

We do have plans to make the wizard more flexible, so that you could configure what is generated - for instance, accessors instead of protected fields etc. Having an option (possibly default) to create a stub for the implementation class is an excellent idea!
(It’s perhaps worth noting that multiple classes can extend the same design, and you might in some cases be able to use the design w/o extending it.)

tl;dr Excellent suggestion!

Best Regards,
Marc

Well, it’s not hard, more of an annoyance. I mean, I edit the named HTML page then switch to the named Java file to add event handlers and the like - it is just natural based upon working on the same named file.

So I either have to leave my code in the wrong place or refactor. It’s really quite annoying.

I think it would have to be easy that for the design Sample, I get Sample.html and AbstractSample.java and Sample.java. Generated code goes to AbstractSample.java and Sample.java, where my code goes, is clean and ready for me to edit.

Otherwise I’m thinking maybe I should be using the name of AbstractSample for the design so I can use the Sample java class. If I create the Sample design then I want to use the Sample java component, not something like SampleEx or some other subclass.

Yes, it is not hard and all based upon managing what you name classes and the like. But the current way the classes are named/created just feels unnatural.