Widget in else clause does not show in Designer

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

Widget in else clause does not show in Designer

Postby diltonm » Wed Apr 15, 2009 8:46 pm

This may be by design but in this example, button_1 is not visible in Designer 6.9.1.200904040059 on Eclipse 3.4.2 Build M20090211-1700:

Code: Select all
   protected void createContents() {
      shell = new Shell();
      shell.setSize(500, 375);
      shell.setText("SWT Application");

      if (true) {
         final Button button = new Button(shell, SWT.NONE);
         button.setText("button");
         button.setBounds(158, 156, 54, 29);
      
      } else {
         final Button button_1 = new Button(shell, SWT.NONE);
         button_1.setText("button_1");
         button_1.setBounds(158, 221, 54, 29);
         
      }
   }
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Widget in else clause does not show in Designer

Postby Eric Clayberg » Thu Apr 16, 2009 5:43 am

That is definitely by design.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Widget in else clause does not show in Designer

Postby diltonm » Thu Apr 16, 2009 6:20 am

Thanks it felt a little disconcerting that a visual design tool could have that type and accuracy of introspecting power. I recall using some other tools on other platforms, they tend to have a hard time parsing their own generated code.

The example was simple to show the point, the way I found this was by pasting the code from:
http://dev.eclipse.org/viewcvs/index.cg ... va?view=co

I noticed that there were no visual controls being rendered.

Anyway, thanks for making a great product, you all deserve the awards you receive.
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Widget in else clause does not show in Designer

Postby Eric Clayberg » Thu Apr 16, 2009 9:50 am

In general, any code found within a conditional (or loop) would be considered to be dynamic code (run as the result of some runtime behavior) and not part of the statically defined GUI definition.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: Widget in else clause does not show in Designer

Postby diltonm » Thu Apr 16, 2009 10:28 am

Thanks for the response.
diltonm
 
Posts: 12
Joined: Sat Apr 04, 2009 7:13 pm

Re: Widget in else clause does not show in Designer

Postby Eric Clayberg » Fri Apr 17, 2009 1:32 pm

There are a couple of exceptions to the conditional rule. The parser will parse into conditions where the conditional test is hard coded to true (as in your example) or does a simple Beans.isDesignTime() test (which is true at design time and false at runtime).

You can also use code hiding tags to change what gets displayed. The following, for example, will cause the second button to be displayed rather than the first:

Code: Select all
   protected void createContents() {
      shell = new Shell();
      shell.setSize(450, 300);
      shell.setText("SWT Application");
      if (true) { //$hide>>$
         final Button button = new Button(shell, SWT.NONE);
         button.setText("button");
         button.setBounds(158, 156, 54, 29);
      } else { //$hide<<$
         final Button button_1 = new Button(shell, SWT.NONE);
         button_1.setText("button_1");
         button_1.setBounds(158, 221, 54, 29);
      }
   }
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests