tibs wrote:I've been playing around with SWT and would like to know if is there any way to structure the code a bit better. I want to add methods with parameters. I don't want to repeat the same block twice if the difference is only in the showed content and in the font style for example. The generated code grows to a size where it becomes really hard to handle. How can I break it into parts that Designer can identify?
You can refactor the code in a variety of ways and Designer will still be able to edit it. Give it a try and see what happens. For example, you can spilt the generated code into pieces. As long as there is some identifiable top-down tree structure, Designer should be able to interpret it. If you spilt the code into multiple methods, make sure that each of those methods is only called once. Using the same code to generate multiple widgets is not supported (too much ambiguity, if you then wanted to change a widget property). For SWT, most sub methods will need to pass in the appropriate parent (either the shell or a composite).
Designer is a true two-way tool (e.g., edit graphically or in code and the changes are reflected in the other). It can read and write almost any format and reverse-engineer most hand-written Java GUI code. It also supports free form code editing (make changes anywhere...not just in "special" areas) and most user refactorings (you can move, rename and subdivide methods without a problem).