2

I wondering why swt is so inconvenient to use. We as programmers have to produce tons of unnecessary source code. Here an example.

Label label = new Label(parent, SWT.NONE);  
label.setText("labelname");  

The minimum would be like this:

createLabel(parent, "labelname");

I build up a convenients library and I would like to know if there is something similar or why SWT or JFace don't go this simple way. Is there any drawback in having some more constructors that cover 80% of the programming task.

Have a more detailed look what I have done.
SWT: More Convenients Please

strangeoptics
  • 753
  • 8
  • 17

3 Answers3

2

I suggest trying Google Window Builder Pro. It is a plugin for Eclipse that allows for the graphical development of GUI's in SWT, Swing, RCP, JFace and others. GWB writes the code which specifies the GUI layout and all you must do is write code to handle events.

Lane Aasen
  • 729
  • 4
  • 14
  • Yes the Window Builder is a realy good tool. I tried it with the simple example in my blog an it produced exact the code I wrote by hand. Unfortunately it doesn't work with my convenient classes. – strangeoptics Oct 02 '11 at 22:15
1

As far as I know there is no such generic library. The one instance which provides some basic factory support for swt control creation is JFace Form Widget. Also have a look at this org.eclipse.ui.forms.widgets.FormToolkit.

From your implementation it appears that you are assuming the GridLayout as the default layouting style. Apart from that a control may have many layout related data like, its indentation (horizontal and vertical), span etc. Which is not easy to cover with factory methods.

If you don't want to put in the extra effort of writing the code for layouting the widgets and all then have a look at the Visual editor at http://www.eclipse.org/archived/.

Also, eclipse itself is moving towards the the Model Driven Generation (http://www.eclipse.org/e4/). It won't be a wonder if we will see a Netbeans like UI designer for SWT (by the way i have written a version for our tool using eclipse modelling framework and GEF).

Still I would suggest you to write the mundane layouting code by hand because it will improve your SWT understanding.

Favonius
  • 13,959
  • 3
  • 55
  • 95
  • Thanks for your reply. When I have time I will answer it. The Visual editor is archived, does it mean the project is stoped? – strangeoptics Sep 29 '11 at 15:59
  • @strangeoptics: Have a look at this SO link http://stackoverflow.com/questions/319242/is-eclipse-visual-editor-dead. To my best of knowledge the project is more-or-less dead. You can also have a look at this project http://cloudgarden.com/jigloo/index.html. – Favonius Sep 30 '11 at 06:37
0

Bytes are very cheap to produce, and I'd debate that SWT "is so inconvenient to use" - well if it's automatically producing it, how is that inconvenient ?

Our computers are so fast that we couldn't even perceive the difference... and time saved is huge.

Caffeinated
  • 11,982
  • 40
  • 122
  • 216
  • 1
    Sorry english is my second language and I misslead you with the sentence "It produces tons of unnecessary code". What I ment was we as a programmer have to produce so much unneccesary code. I will fix my original question. – strangeoptics Sep 28 '11 at 06:15
  • But I am with your opinion that some more byte code doesn't matter. – strangeoptics Sep 28 '11 at 06:21