Custom Widget's BeanInfo Class

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

Custom Widget's BeanInfo Class

Postby myerramalli » Mon Aug 30, 2004 10:21 am

I have a custom widget and I want to expose some of its properties using BeanInfo Class. I have written the BeanInfo Class, placed it in the same directory where my custom widget class is, packaged into jar and exported the jar to my test project.
The Designer does not expose my properties (does not seem to recognize my BeanInfo Class). Do I have set the Designer's Introspector's search path? If so, How should I do this??
Below is the code of my BeanInfo class.

public class ButtonBeanInfo extends SimpleBeanInfo {
PropertyDescriptor propDes[];
public PropertyDescriptor[] getPropertyDescriptor(){
//Class beanClass = new Button(null,-1).getClass();
try{
PropertyDescriptor text = new PropertyDescriptor("Text",
beanClass);
PropertyDescriptor image = new PropertyDescriptor("Image
", beanClass);
text.setBound(true);
image.setBound(true);
PropertyDescriptor propDes[] = {text,image};

}catch(IntrospectionException e){

}
return propDes;
}
public BeanDescriptor getBeanDescriptor(){
return new BeanDescriptor(beanClass);
}
private final static Class beanClass = Button.class;
myerramalli
 
Posts: 16
Joined: Thu Aug 26, 2004 4:32 pm

Re: Custom Widget's BeanInfo Class

Postby Eric Clayberg » Mon Aug 30, 2004 10:50 am

Can you post the source for yoru Button class as well?
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

Postby myerramalli » Mon Aug 30, 2004 11:50 am

Sorry, I cannot post the source of the Button. But I can say that it has the following inheritence hierarchy org.eclipse.swt.widgets.Widget,org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable,org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas and few other custom classes

You have stated the following sentence in your previous email,

>If you subclass an existing SWT widget, your subclass will inherit all of the superclass's properties. If your widget further defines public getter/setter pairs, those will be picked up as custom properties.

The above custom widget does have public getter/setter methods, but the designer does not show them on the pallette. How can I see the custom properties?

How can I make my custom widget expose its own properties. Does writing the BeanInfo class help me in anyway? What are the possible solutions to the above problem?

Please advice me in this regard. I greatly appreciate your reply!!
Last edited by myerramalli on Mon Aug 30, 2004 12:22 pm, edited 1 time in total.
myerramalli
 
Posts: 16
Joined: Thu Aug 26, 2004 4:32 pm

Postby Eric Clayberg » Mon Aug 30, 2004 12:20 pm

myerramalli wrote:Sorry, I cannot post the source of the Button.
You have stated the following sentence in your previous email,

>If you subclass an existing SWT widget, your subclass will inherit all of the superclass's properties. If your widget further defines public getter/setter pairs, those will be picked up as custom properties.

The above custom widget does have public getter/setter methods, but the designer does not show them on the pallette. How can I see the custom properties?

OK. Now I am quite confused. You are asking this question in the Swing Designer forum, so I assumed you were referring to a custom Swing widget, not a custom SWT widget.

SWT does not (yet) define any BeanInfo API. There is some work going on in the VE project to provide a BeanInfo API based on Sweet. That work is still very preliminary. Once it is completed and Eclipse publicly supports BeanInfo for SWT, we will support that in Designer. For now, we can only support BeanInfo for Swing widgets. If the BeanInfo class you posted earlier in this thread is for an SWT class, it won't be recognized. Had I known you were talking about SWT rather than Swing, I would have told you that earlier.

As to custom SWT widgets, they will inherit their superclass's properties. If your widget further defines public getter/setter pairs, those will be picked up as custom properties and displayed in the "custom" properties list. Currently, Designer supports custom String, String[], int, boolean, Font and Color properties.

Here is a screen shot of an SWT Button subclass with several custom properties:

Image

If your custom properties are not showing up, make sure that you define a matching public getter/setter pair and that they use one of the supported property types. Beyond that, I don't know what to tell you. If you want further help, you will need to send us the code for the custom widget or an approximation (without that, I have no idea what you are actually doing).
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

Postby myerramalli » Mon Aug 30, 2004 12:31 pm

Sorry for the confusion. I am not aware that I am positing the message in the Swing Designer support . thank you for the patient reply.
I don't see the Custom node in the property pallatte. I will get back to you .
myerramalli
 
Posts: 16
Joined: Thu Aug 26, 2004 4:32 pm

Postby Eric Clayberg » Mon Aug 30, 2004 12:34 pm

myerramalli wrote:Sorry for the confusion. I am not aware that I am positing the message in the Swing Designer support . thank you for the patient reply.
I don't see the Custom node in the property pallatte. I will get back to you .

Again, if you send me the source for the custom widget (or an approximation), I can probably figure out why that is the case pretty quickly.
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

Postby Guest » Mon Aug 30, 2004 2:44 pm

Since the file is big I have sent attachment the source to support@swt-designer.com
Please post your response in this thread
Guest
 

Postby myerramalli » Mon Aug 30, 2004 2:47 pm

Since the file is big . I have sent the file as attachment to support@swt-designer.com
Please post your response in this thread.
myerramalli
 
Posts: 16
Joined: Thu Aug 26, 2004 4:32 pm

Postby Eric Clayberg » Mon Aug 30, 2004 7:48 pm

myerramalli wrote:Since the file is big . I have sent the file as attachment to support@swt-designer.com
Please post your response in this thread.

I got your example. Thanks.

When I tried your custom Button widget in Designer, it identified four custom properties. Here's a screen shot...

Image

Here's some sample generated code after setting some of the custom properties...

Image

Are you seeing something different? Should additional properties been discovered?
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

Postby myerramalli » Tue Aug 31, 2004 10:32 am

Here are 2 variations
1. Created a project, created a class, pasted the code of Custom Widget,built the project and placed the custm widget on the Custom Controls pallette.Created a swt application and layed out the widget.
-> I was able to see the custom properties in the property pallette

2. Created a project, included the jar file that contains my custom Widgets. placed the widgets on the Custom Controls, created a swt application and layed out the widget.
-->Could not see the custom properties

Why does not designer able to recognize the properties when the widgets come from a jar file?
myerramalli
 
Posts: 16
Joined: Thu Aug 26, 2004 4:32 pm

Postby Eric Clayberg » Tue Aug 31, 2004 12:18 pm

myerramalli wrote:Here are 2 variations
1. Created a project, created a class, pasted the code of Custom Widget,built the project and placed the custm widget on the Custom Controls pallette.Created a swt application and layed out the widget.
-> I was able to see the custom properties in the property pallette

2. Created a project, included the jar file that contains my custom Widgets. placed the widgets on the Custom Controls, created a swt application and layed out the widget.
-->Could not see the custom properties

Why does not designer able to recognize the properties when the widgets come from a jar file?

In order to show the custom properties, Designer needs to be able to parse the source for the custom widget class and build a corresponding AST model. I am guessing that it can't do that with a binary class sitting in a jar file. Once Eclipse supports a bean info model for SWT, we will be able to get all of the custom properties via the bean info API.
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: Google [Bot] and 1 guest