Design mode vs. execution mode

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

Design mode vs. execution mode

Postby kvocat » Thu Jun 22, 2006 3:51 am

Hi !

We have problems with custom controls in design mode. SWT Designer is unable to interpret our code. For example, these error messages :

We don't understand how the Designer works. In design mode, we just want to see and work with graphical controls (composite, text, labels...) and we don't want to know which are datas displayed in these controls.

A little example :
we have an xml property file in which are the traductions for several languages. When we set the text to the label, text, composite ... using a function, Designer is unable to display this control and generates an error (in Design Mode).
Code: Select all
Label myLabel = new Label(body, "", SWT.NONE);
myLabel.setText(MyStaticClass.getValue("fr", "UserId"));

Why do you try to interpret the setText of this control ?
We understand you parse the code for displaying graphical controls, but why to try to interpret the business around this control ?
Why not to catch the error when the setText() is done and go one with the next instruction ?

If you use the Beans.isDesignTime() in your code, you know when you are in design and then do :
Code: Select all
else in execution mode, execute the real code :
Code: Select all
myLabel.setText(MyStaticClass.getValue("fr", "UserId"));

We think it isn't our job to differentiate in our code, portions to execute in Design Mode and others portions in Execution Mode. We should modify a lot of things in our project with your solution (...Beans.isDesignTime()...).

Have you an other solution on your side ?

Thanks a lot and have a nice day.

Posts: 1
Joined: Thu Jun 22, 2006 2:26 am

Re: Design mode vs. execution mode

Postby Eric Clayberg » Thu Jun 22, 2006 5:52 am

Designer instantiates custom controls exactly like any other widget. It does not parse the code for a custom widget; it instantiates an instance of the custom widget using its public constructor (which causes the code for the custom widget to be executed). If the custom widget throws an exception during invocation, Designer can't use the control and the exception will be recorded to the log.

It is your responsibility as the bean provider to make sure that your component can be instantiated properly at both runtime and design time. If you have runtime specific code that fails at design time, you need to fix the underlying problem (e.g., prevent the NullPointerException in your case) or wrapper that code in a call to Beans.isDesignTime().

This is not an arbitrary concept imposed by Designer; this is a basic Java Bean concept. The Beans.isDesignTime() construct is not something we made up. It is a basic part of Java as delivered by Sun. It is specifically intended to make it possible for custom components with unique runtime requirements to work in a design time environment like a GUI builder. All major GUI builders support Beans.isDesignTime() for this very purpose.
Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
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 1 guest