Bean Info getJavaInitializationString()

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

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

Bean Info getJavaInitializationString()

Postby munal » Thu Oct 01, 2009 3:14 am

Hi,

I've a custom property editor for a custom widget. My property editor returns a Java code
which refers a class in classpath. For example;

Code: Select all
myButton.setSettings(
  //property editor begins
  new ButtonSettings {
    "test", //Button Test
    BAlignment.LEFT //an enum class in classpath    
  } 
  //property editor ends
);


The problem is that WindowBuilder does not import BAlignment class automatically.

In WindowBuilder 6.9.2,
The designer is adding the java code, but eclipse is giving an import error. And designer
is not refreshing widget Alignment.

In WindowBuilder 7.1
The designer is crashing the code with an error.

If you return the fullpath of the class, probably you won't get an error. Bu it looks awful.

Code: Select all
myButton.setSettings(
  //property editor begins
  new ButtonSettings {
    "test", //Button Test
    org.myproject.mypacket.mysubpacket.BAlignment.LEFT //an enum class in classpath    
  } 
  //property editor ends
);


Is there an another way of doing this?

Thanks.
munal
 
Posts: 5
Joined: Thu Oct 01, 2009 2:01 am

Re: Bean Info getJavaInitializationString()

Postby Eric Clayberg » Thu Oct 01, 2009 4:50 am

See the JavaDoc for getJavaInitializationString()...

Code: Select all
     * The code fragment should be context free and must be a legal Java
     * expression as specified by the JLS.
     * <p>
     * Specifically, if the expression represents a computation then all
     * classes and static members should be fully qualified. This rule
     * applies to constructors, static methods and non primitive arguments.

Any class refs need to be fully qualified as in your second example.
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 Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest