Creating a new Class

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Creating a new Class

Postby volcano » Thu Aug 28, 2003 3:39 pm

I've just started getting into SWT and was pleased to stumble across this designer - looks great!

A few questions though.

1. Whilst in Eclipse, if I create a brand new class (file > new > class) and open it with the swt-designer, I don't get anything at all in the design view, nor can I add anything to create the Shell or Display. Surely I am missing something.

2. I downloaded a few example apps and compiled them using the normal eclipse IDE view, but when I try and open them using swt-designer, I get errors about "Only one control creation supported in one block". What exactly does this mean?

3. When I followed the example you have for creating a JFace Wizard Page, I dont get the extra widgets that you have, i.e. the Top and Bottom composites with the labels and so forth. I only get a blank shell.
volcano
 
Posts: 1
Joined: Thu Aug 28, 2003 2:56 pm

Re: Creating a new Class

Postby admin » Thu Aug 28, 2003 8:09 pm

volcano wrote:I've just started getting into SWT and was pleased to stumble across this designer - looks great!

Thank you :-)

volcano wrote:1. Whilst in Eclipse, if I create a brand new class (file > new > class) and open it with the swt-designer, I don't get anything at all in the design view, nor can I add anything to create the Shell or Display. Surely I am missing something.

Yes. Class sould have already some set of controls before Designer can open it. Use File | New | Other and then SWT in tree.

volcano wrote:2. I downloaded a few example apps and compiled them using the normal eclipse IDE view, but when I try and open them using swt-designer, I get errors about "Only one control creation supported in one block". What exactly does this mean?

Sure.
Designer moves controls, so to make clear what pieces of code to move with control, all code for control should be in separate block. Here is example.
Code: Select all
   public static void main(String[] args) {
      final Display display = new Display();
      final Shell shell = new Shell();
      shell.setLayout(new GridLayout());
      shell.setText("SWT Application");
      {
         final Button button = new Button(shell, SWT.NONE);
         button.setText("button");
      }
      {
         final Text text = new Text(shell, SWT.BORDER);
         text.setText("text");
      }
      // DESIGNER: Add controls before this line.
      shell.open();
      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }
   }


volcano wrote:3. When I followed the example you have for creating a JFace Wizard Page, I dont get the extra widgets that you have, i.e. the Top and Bottom composites with the labels and so forth. I only get a blank shell.

Yes, JFace Wizard is supported only in professional version.
admin
Moderator
 
Posts: 166
Joined: Thu Jul 24, 2003 12:25 am

Re: Creating a new Class

Postby Paul Singleton » Wed Sep 24, 2003 6:36 am

volcano wrote:1. Whilst in Eclipse, if I create a brand new class (file > new > class) and open it with the swt-designer, I don't get anything at all in the design view, nor can I add anything to create the Shell or Display. Surely I am missing something.

This baffled me for an hour or so :?
It is frustrating (and counter-intuitive?) to be staring at a GUI designer with which one can do absolutely nothing :roll:
If I deliberately open a Java file with the Designer, and it can't design until I do some other voodoo, I suggest a dialog, warning or hint. Or a button to do it all for me :wink:

NB if I open a stubless new class with Designer, I don't even get the Design tab :?:

I'm not complaining (I'm still here arent I?!) but worry that such things might put off other, less motivated, folk...
Paul Singleton
Jambusters Ltd
Paul Singleton
 
Posts: 7
Joined: Wed Sep 24, 2003 4:33 am
Location: CREWE, England

Postby admin » Wed Sep 24, 2003 8:57 pm

You are right, documentation is not very good, we should describe, how to create new class that can be used with Designer (i.e. using our wizards). One possible positive thing here is that in our flash demos we always start with wizard.

BTW, what should do such button?
admin
Moderator
 
Posts: 166
Joined: Thu Jul 24, 2003 12:25 am

Postby Paul Singleton » Thu Sep 25, 2003 5:59 am

admin wrote:BTW, what should do such button?

How about this (I realise you do some of this already):
Code: Select all
If the class has no methods with GUI Then
    If the class has no main() Then
        offer to "convert the class to an SWT app"
        (by adding a main() with blank shell as the wizard does)
    Else
        offer to add a blank shell to existing main()
        (don't worry about sticking a dispatch loop in at this stage)
    Fi
Else
    ...other checks:
        warn of methods with incompatible GUI code?
        open the method with most shells?
Fi

I know this is probably irrelevant to expert users, but it might help beginners to get playing with it before they really know what they are doing :wink:
Paul Singleton
Jambusters Ltd
Paul Singleton
 
Posts: 7
Joined: Wed Sep 24, 2003 4:33 am
Location: CREWE, England


Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest